Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
a1f9a333
Unverified
Kaydet (Commit)
a1f9a333
authored
Ock 30, 2019
tarafından
Steve Dower
Kaydeden (comit)
GitHub
Ock 30, 2019
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-35854: Fix EnvBuilder and --symlinks in venv on Windows (GH-11700)
üst
40ebe948
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
62 additions
and
26 deletions
+62
-26
venv.rst
Doc/library/venv.rst
+13
-9
venv-create.inc
Doc/using/venv-create.inc
+5
-0
test_venv.py
Lib/test/test_venv.py
+0
-1
__init__.py
Lib/venv/__init__.py
+43
-16
2019-01-29-15-44-46.bpo-35854.Ww3z19.rst
...S.d/next/Windows/2019-01-29-15-44-46.bpo-35854.Ww3z19.rst
+1
-0
No files found.
Doc/library/venv.rst
Dosyayı görüntüle @
a1f9a333
...
@@ -109,8 +109,7 @@ creation according to their needs, the :class:`EnvBuilder` class.
...
@@ -109,8 +109,7 @@ creation according to their needs, the :class:`EnvBuilder` class.
any existing target directory, before creating the environment.
any existing target directory, before creating the environment.
* ``symlinks`` -- a Boolean value indicating whether to attempt to symlink the
* ``symlinks`` -- a Boolean value indicating whether to attempt to symlink the
Python binary (and any necessary DLLs or other binaries,
Python binary rather than copying.
e.g. ``pythonw.exe``), rather than copying.
* ``upgrade`` -- a Boolean value which, if true, will upgrade an existing
* ``upgrade`` -- a Boolean value which, if true, will upgrade an existing
environment with the running Python - for use when that Python has been
environment with the running Python - for use when that Python has been
...
@@ -176,15 +175,15 @@ creation according to their needs, the :class:`EnvBuilder` class.
...
@@ -176,15 +175,15 @@ creation according to their needs, the :class:`EnvBuilder` class.
.. method:: setup_python(context)
.. method:: setup_python(context)
Creates a copy o
f the Python executable in the environment on POSIX
Creates a copy o
r symlink to the Python executable in the environment.
systems. If a specific executable ``python3.x`` was used, symlinks to
On POSIX systems, if a specific executable ``python3.x`` was used,
``python`` and ``python3`` will be created pointing to that executable,
symlinks to ``python`` and ``python3`` will be created pointing to that
unless files with those names already exist.
executable,
unless files with those names already exist.
.. method:: setup_scripts(context)
.. method:: setup_scripts(context)
Installs activation scripts appropriate to the platform into the virtual
Installs activation scripts appropriate to the platform into the virtual
environment.
On Windows, also installs the ``python[w].exe`` scripts.
environment.
.. method:: post_setup(context)
.. method:: post_setup(context)
...
@@ -194,8 +193,13 @@ creation according to their needs, the :class:`EnvBuilder` class.
...
@@ -194,8 +193,13 @@ creation according to their needs, the :class:`EnvBuilder` class.
.. versionchanged:: 3.7.2
.. versionchanged:: 3.7.2
Windows now uses redirector scripts for ``python[w].exe`` instead of
Windows now uses redirector scripts for ``python[w].exe`` instead of
copying the actual binaries, and so :meth:`setup_python` does nothing
copying the actual binaries. In 3.7.2 only :meth:`setup_python` does
unless running from a build in the source tree.
nothing unless running from a build in the source tree.
.. versionchanged:: 3.7.3
Windows copies the redirector scripts as part of :meth:`setup_python`
instead of :meth:`setup_scripts`. This was not the case in 3.7.2.
When using symlinks, the original executables will be linked.
In addition, :class:`EnvBuilder` provides this utility method that can be
In addition, :class:`EnvBuilder` provides this utility method that can be
called from :meth:`setup_scripts` or :meth:`post_setup` in subclasses to
called from :meth:`setup_scripts` or :meth:`post_setup` in subclasses to
...
...
Doc/using/venv-create.inc
Dosyayı görüntüle @
a1f9a333
...
@@ -70,6 +70,11 @@ The command, if run with ``-h``, will show the available options::
...
@@ -70,6 +70,11 @@ The command, if run with ``-h``, will show the available options::
In earlier versions, if the target directory already existed, an error was
In earlier versions, if the target directory already existed, an error was
raised, unless the ``--clear`` or ``--upgrade`` option was provided.
raised, unless the ``--clear`` or ``--upgrade`` option was provided.
.. note::
While symlinks are supported on Windows, they are not recommended. Of
particular note is that double-clicking ``python.exe`` in File Explorer
will resolve the symlink eagerly and ignore the virtual environment.
The created ``pyvenv.cfg`` file also includes the
The created ``pyvenv.cfg`` file also includes the
``include-system-site-packages`` key, set to ``true`` if ``venv`` is
``include-system-site-packages`` key, set to ``true`` if ``venv`` is
run with the ``--system-site-packages`` option, ``false`` otherwise.
run with the ``--system-site-packages`` option, ``false`` otherwise.
...
...
Lib/test/test_venv.py
Dosyayı görüntüle @
a1f9a333
...
@@ -243,7 +243,6 @@ class BasicTest(BaseTest):
...
@@ -243,7 +243,6 @@ class BasicTest(BaseTest):
self
.
assertIn
(
'include-system-site-packages =
%
s
\n
'
%
s
,
data
)
self
.
assertIn
(
'include-system-site-packages =
%
s
\n
'
%
s
,
data
)
@unittest.skipUnless
(
can_symlink
(),
'Needs symlinks'
)
@unittest.skipUnless
(
can_symlink
(),
'Needs symlinks'
)
@unittest.skipIf
(
os
.
name
==
'nt'
,
'Symlinks are never used on Windows'
)
def
test_symlinking
(
self
):
def
test_symlinking
(
self
):
"""
"""
Test symlinking works as expected
Test symlinking works as expected
...
...
Lib/venv/__init__.py
Dosyayı görüntüle @
a1f9a333
...
@@ -64,11 +64,10 @@ class EnvBuilder:
...
@@ -64,11 +64,10 @@ class EnvBuilder:
self
.
system_site_packages
=
False
self
.
system_site_packages
=
False
self
.
create_configuration
(
context
)
self
.
create_configuration
(
context
)
self
.
setup_python
(
context
)
self
.
setup_python
(
context
)
if
not
self
.
upgrade
:
self
.
setup_scripts
(
context
)
if
self
.
with_pip
:
if
self
.
with_pip
:
self
.
_setup_pip
(
context
)
self
.
_setup_pip
(
context
)
if
not
self
.
upgrade
:
if
not
self
.
upgrade
:
self
.
setup_scripts
(
context
)
self
.
post_setup
(
context
)
self
.
post_setup
(
context
)
if
true_system_site_packages
:
if
true_system_site_packages
:
# We had set it to False before, now
# We had set it to False before, now
...
@@ -176,6 +175,23 @@ class EnvBuilder:
...
@@ -176,6 +175,23 @@ class EnvBuilder:
logger
.
warning
(
'Unable to symlink
%
r to
%
r'
,
src
,
dst
)
logger
.
warning
(
'Unable to symlink
%
r to
%
r'
,
src
,
dst
)
force_copy
=
True
force_copy
=
True
if
force_copy
:
if
force_copy
:
if
os
.
name
==
'nt'
:
# On Windows, we rewrite symlinks to our base python.exe into
# copies of venvlauncher.exe
basename
,
ext
=
os
.
path
.
splitext
(
os
.
path
.
basename
(
src
))
if
basename
.
endswith
(
'_d'
):
ext
=
'_d'
+
ext
basename
=
basename
[:
-
2
]
if
sysconfig
.
is_python_build
(
True
):
if
basename
==
'python'
:
basename
=
'venvlauncher'
elif
basename
==
'pythonw'
:
basename
=
'venvwlauncher'
scripts
=
os
.
path
.
dirname
(
src
)
else
:
scripts
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
"scripts"
,
"nt"
)
src
=
os
.
path
.
join
(
scripts
,
basename
+
ext
)
shutil
.
copyfile
(
src
,
dst
)
shutil
.
copyfile
(
src
,
dst
)
def
setup_python
(
self
,
context
):
def
setup_python
(
self
,
context
):
...
@@ -202,23 +218,31 @@ class EnvBuilder:
...
@@ -202,23 +218,31 @@ class EnvBuilder:
if
not
os
.
path
.
islink
(
path
):
if
not
os
.
path
.
islink
(
path
):
os
.
chmod
(
path
,
0
o755
)
os
.
chmod
(
path
,
0
o755
)
else
:
else
:
# For normal cases, the venvlauncher will be copied from
if
self
.
symlinks
:
# our scripts folder. For builds, we need to copy it
# For symlinking, we need a complete copy of the root directory
# manually.
# If symlinks fail, you'll get unnecessary copies of files, but
# we assume that if you've opted into symlinks on Windows then
# you know what you're doing.
suffixes
=
[
f
for
f
in
os
.
listdir
(
dirname
)
if
os
.
path
.
normcase
(
os
.
path
.
splitext
(
f
)[
1
])
in
(
'.exe'
,
'.dll'
)
]
if
sysconfig
.
is_python_build
(
True
):
if
sysconfig
.
is_python_build
(
True
):
suffix
=
'.exe'
suffixes
=
[
if
context
.
python_exe
.
lower
()
.
endswith
(
'_d.exe'
):
f
for
f
in
suffixes
if
suffix
=
'_d.exe'
os
.
path
.
normcase
(
f
)
.
startswith
((
'python'
,
'vcruntime'
))
]
src
=
os
.
path
.
join
(
dirname
,
"venvlauncher"
+
suffix
)
else
:
dst
=
os
.
path
.
join
(
binpath
,
context
.
python_exe
)
suffixes
=
[
'python.exe'
,
'python_d.exe'
,
'pythonw.exe'
,
copier
(
src
,
dst
)
'pythonw_d.exe'
]
src
=
os
.
path
.
join
(
dirname
,
"venvwlauncher"
+
suffix
)
for
suffix
in
suffixes
:
dst
=
os
.
path
.
join
(
binpath
,
"pythonw"
+
suffix
)
src
=
os
.
path
.
join
(
dirname
,
suffix
)
copier
(
src
,
dst
)
if
os
.
path
.
exists
(
src
):
copier
(
src
,
os
.
path
.
join
(
binpath
,
suffix
))
# copy init.tcl over
if
sysconfig
.
is_python_build
(
True
):
# copy init.tcl
for
root
,
dirs
,
files
in
os
.
walk
(
context
.
python_dir
):
for
root
,
dirs
,
files
in
os
.
walk
(
context
.
python_dir
):
if
'init.tcl'
in
files
:
if
'init.tcl'
in
files
:
tcldir
=
os
.
path
.
basename
(
root
)
tcldir
=
os
.
path
.
basename
(
root
)
...
@@ -304,6 +328,9 @@ class EnvBuilder:
...
@@ -304,6 +328,9 @@ class EnvBuilder:
dirs
.
remove
(
d
)
dirs
.
remove
(
d
)
continue
# ignore files in top level
continue
# ignore files in top level
for
f
in
files
:
for
f
in
files
:
if
(
os
.
name
==
'nt'
and
f
.
startswith
(
'python'
)
and
f
.
endswith
((
'.exe'
,
'.pdb'
))):
continue
srcfile
=
os
.
path
.
join
(
root
,
f
)
srcfile
=
os
.
path
.
join
(
root
,
f
)
suffix
=
root
[
plen
:]
.
split
(
os
.
sep
)[
2
:]
suffix
=
root
[
plen
:]
.
split
(
os
.
sep
)[
2
:]
if
not
suffix
:
if
not
suffix
:
...
...
Misc/NEWS.d/next/Windows/2019-01-29-15-44-46.bpo-35854.Ww3z19.rst
0 → 100644
Dosyayı görüntüle @
a1f9a333
Fix EnvBuilder and --symlinks in venv on Windows
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment