Skip to content

Commit 4441b2b

Browse files
committed
gh-129382: Match venv API symlink defaults to the CLI
1 parent 46c355f commit 4441b2b

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

‎Lib/venv/__init__.py‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,15 @@ class EnvBuilder:
2727
By default, the builder makes the system (global) site-packages dir
2828
*un*available to the created environment.
2929
30-
If invoked using the Python -m option, the default is to use copying
31-
on Windows platforms but symlinks elsewhere. If instantiated some
32-
other way, the default is to *not* use symlinks.
30+
By default, the builder uses copying on Windows platforms but symlinks
31+
elsewhere, matching the behaviour when invoked using the Python -m option.
3332
3433
:param system_site_packages: If True, the system (global) site-packages
3534
dir is available to created environments.
3635
:param clear: If True, delete the contents of the environment directory if
3736
it already exists, before environment creation.
3837
:param symlinks: If True, attempt to symlink rather than copy files into
39-
virtual environment.
38+
virtual environment. If None, use the platform default.
4039
:param upgrade: If True, upgrade an existing virtual environment.
4140
:param with_pip: If True, ensure pip is installed in the virtual
4241
environment
@@ -47,11 +46,11 @@ class EnvBuilder:
4746
"""
4847

4948
def __init__(self, system_site_packages=False, clear=False,
50-
symlinks=False, upgrade=False, with_pip=False, prompt=None,
49+
symlinks=None, upgrade=False, with_pip=False, prompt=None,
5150
upgrade_deps=False, *, scm_ignore_files=frozenset()):
5251
self.system_site_packages = system_site_packages
5352
self.clear = clear
54-
self.symlinks = symlinks
53+
self.symlinks = os.name != 'nt' if symlinks is None else symlinks
5554
self.upgrade = upgrade
5655
self.with_pip = with_pip
5756
self.orig_prompt = prompt
@@ -607,7 +606,7 @@ def upgrade_dependencies(self, context):
607606

608607

609608
def create(env_dir, system_site_packages=False, clear=False,
610-
symlinks=False, with_pip=False, prompt=None, upgrade_deps=False,
609+
symlinks=None, with_pip=False, prompt=None, upgrade_deps=False,
611610
*, scm_ignore_files=frozenset()):
612611
"""Create a virtual environment in a directory."""
613612
builder = EnvBuilder(system_site_packages=system_site_packages,

0 commit comments

Comments
 (0)