From 37d82d82e61a8a0b80f32f213a1d4030148e9745 Mon Sep 17 00:00:00 2001 From: "Mark E. Haase" Date: Mon, 25 Jul 2016 13:33:15 -0400 Subject: [PATCH] Fix issue 24875. Force system_site_packages to False before bootstrapping pip (even if the --system-site-packages flag is present), then change it to the user's request after bootstrapping pip. --- Lib/venv/__init__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Lib/venv/__init__.py b/Lib/venv/__init__.py index fa3d2a3..c389e06 100644 --- a/Lib/venv/__init__.py +++ b/Lib/venv/__init__.py @@ -55,13 +55,14 @@ class EnvBuilder: """ env_dir = os.path.abspath(env_dir) context = self.ensure_directories(env_dir) - self.create_configuration(context) + self.create_configuration(context, system_site_packages=False) self.setup_python(context) if self.with_pip: self._setup_pip(context) if not self.upgrade: self.setup_scripts(context) self.post_setup(context) + self.create_configuration(context, self.system_site_packages) def clear_directory(self, path): for fn in os.listdir(path): @@ -126,7 +127,7 @@ class EnvBuilder: create_if_needed(binpath) return context - def create_configuration(self, context): + def create_configuration(self, context, system_site_packages): """ Create a configuration file indicating where the environment's Python was copied from, and whether the system site-packages should be made @@ -138,7 +139,7 @@ class EnvBuilder: context.cfg_path = path = os.path.join(context.env_dir, 'pyvenv.cfg') with open(path, 'w', encoding='utf-8') as f: f.write('home = %s\n' % context.python_dir) - if self.system_site_packages: + if system_site_packages: incl = 'true' else: incl = 'false' -- 2.7.4 (Apple Git-66)