summaryrefslogtreecommitdiffstats
path: root/Lib/venv
diff options
context:
space:
mode:
authorSteve Dower <steve.dower@microsoft.com>2018-09-20 20:38:34 (GMT)
committerGitHub <noreply@github.com>2018-09-20 20:38:34 (GMT)
commitf14c28f39766855420dd58d209da4ad847f3030e (patch)
tree79b95924f711b99388b2899c119ae31f31ad2ce5 /Lib/venv
parentbc854750589d4de0fd55693963964e0558b5c8ac (diff)
downloadcpython-f14c28f39766855420dd58d209da4ad847f3030e.zip
cpython-f14c28f39766855420dd58d209da4ad847f3030e.tar.gz
cpython-f14c28f39766855420dd58d209da4ad847f3030e.tar.bz2
bpo-34011: Fixes missing venv files and other tests (GH-9458)
Diffstat (limited to 'Lib/venv')
-rw-r--r--Lib/venv/__init__.py48
1 files changed, 25 insertions, 23 deletions
diff --git a/Lib/venv/__init__.py b/Lib/venv/__init__.py
index e0ab241..0434208 100644
--- a/Lib/venv/__init__.py
+++ b/Lib/venv/__init__.py
@@ -208,11 +208,9 @@ class EnvBuilder:
copier(context.env_exe, path, relative_symlinks_ok=True)
if not os.path.islink(path):
os.chmod(path, 0o755)
- elif sysconfig.is_python_build(True):
- # See bpo-34011. This copying code should only be needed when a
- # venv is created from a source Python build (i.e. not an installed
- # Python)
- subdir = 'DLLs'
+ else:
+ # See bpo-34011. When using a proper install, we should only need to
+ # copy the top-level of DLLs.
include = self.include_binary
files = [f for f in os.listdir(dirname) if include(f)]
for f in files:
@@ -220,24 +218,28 @@ class EnvBuilder:
dst = os.path.join(binpath, f)
if dst != context.env_exe: # already done, above
copier(src, dst)
- dirname = os.path.join(dirname, subdir)
- if os.path.isdir(dirname):
- files = [f for f in os.listdir(dirname) if include(f)]
- for f in files:
- src = os.path.join(dirname, f)
- dst = os.path.join(binpath, f)
- copier(src, dst)
- # copy init.tcl over
- for root, dirs, files in os.walk(context.python_dir):
- if 'init.tcl' in files:
- tcldir = os.path.basename(root)
- tcldir = os.path.join(context.env_dir, 'Lib', tcldir)
- if not os.path.exists(tcldir):
- os.makedirs(tcldir)
- src = os.path.join(root, 'init.tcl')
- dst = os.path.join(tcldir, 'init.tcl')
- shutil.copyfile(src, dst)
- break
+
+ # When creating from a build directory, we continue to copy all files.
+ if sysconfig.is_python_build(True):
+ subdir = 'DLLs'
+ dirname = os.path.join(dirname, subdir)
+ if os.path.isdir(dirname):
+ files = [f for f in os.listdir(dirname) if include(f)]
+ for f in files:
+ src = os.path.join(dirname, f)
+ dst = os.path.join(binpath, f)
+ copier(src, dst)
+ # copy init.tcl over
+ for root, dirs, files in os.walk(context.python_dir):
+ if 'init.tcl' in files:
+ tcldir = os.path.basename(root)
+ tcldir = os.path.join(context.env_dir, 'Lib', tcldir)
+ if not os.path.exists(tcldir):
+ os.makedirs(tcldir)
+ src = os.path.join(root, 'init.tcl')
+ dst = os.path.join(tcldir, 'init.tcl')
+ shutil.copyfile(src, dst)
+ break
def _setup_pip(self, context):
"""Installs or upgrades pip in a virtual environment"""