Make pip installable in a new venv when using the --system-site-packages flag
This commit is contained in:
parent
ef0529a8c3
commit
6b23e951bc
|
@ -0,0 +1,78 @@
|
||||||
|
diff --git a/Lib/test/test_venv.py b/Lib/test/test_venv.py
|
||||||
|
index 3999d1f..c1e6566 100644
|
||||||
|
--- a/Lib/test/test_venv.py
|
||||||
|
+++ b/Lib/test/test_venv.py
|
||||||
|
@@ -328,13 +328,7 @@ def test_devnull_exists_and_is_empty(self):
|
||||||
|
with open(os.devnull, "rb") as f:
|
||||||
|
self.assertEqual(f.read(), b"")
|
||||||
|
|
||||||
|
- # Requesting pip fails without SSL (http://bugs.python.org/issue19744)
|
||||||
|
- @unittest.skipIf(ssl is None, ensurepip._MISSING_SSL_MESSAGE)
|
||||||
|
- @unittest.skipUnless(threading, 'some dependencies of pip import threading'
|
||||||
|
- ' module unconditionally')
|
||||||
|
- # Issue #26610: pip/pep425tags.py requires ctypes
|
||||||
|
- @unittest.skipUnless(ctypes, 'pip requires ctypes')
|
||||||
|
- def test_with_pip(self):
|
||||||
|
+ def do_test_with_pip(self, system_site_packages):
|
||||||
|
rmtree(self.env_dir)
|
||||||
|
with EnvironmentVarGuard() as envvars:
|
||||||
|
# pip's cross-version compatibility may trigger deprecation
|
||||||
|
@@ -368,6 +362,7 @@ def test_with_pip(self):
|
||||||
|
# config in place to ensure we ignore it
|
||||||
|
try:
|
||||||
|
self.run_with_capture(venv.create, self.env_dir,
|
||||||
|
+ system_site_packages=system_site_packages,
|
||||||
|
with_pip=True)
|
||||||
|
except subprocess.CalledProcessError as exc:
|
||||||
|
# The output this produces can be a little hard to read,
|
||||||
|
@@ -417,9 +412,21 @@ def test_with_pip(self):
|
||||||
|
out = out.decode("latin-1") # Force to text, prevent decoding errors
|
||||||
|
self.assertIn("Successfully uninstalled pip", out)
|
||||||
|
self.assertIn("Successfully uninstalled setuptools", out)
|
||||||
|
- # Check pip is now gone from the virtual environment
|
||||||
|
- self.assert_pip_not_installed()
|
||||||
|
+ # Check pip is now gone from the virtual environment. This only
|
||||||
|
+ # applies in the system_site_packages=False case, because in the
|
||||||
|
+ # other case, pip may still be available in the system site-packages
|
||||||
|
+ if not system_site_packages:
|
||||||
|
+ self.assert_pip_not_installed()
|
||||||
|
|
||||||
|
+ # Requesting pip fails without SSL (http://bugs.python.org/issue19744)
|
||||||
|
+ @unittest.skipIf(ssl is None, ensurepip._MISSING_SSL_MESSAGE)
|
||||||
|
+ @unittest.skipUnless(threading, 'some dependencies of pip import threading'
|
||||||
|
+ ' module unconditionally')
|
||||||
|
+ # Issue #26610: pip/pep425tags.py requires ctypes
|
||||||
|
+ @unittest.skipUnless(ctypes, 'pip requires ctypes')
|
||||||
|
+ def test_with_pip(self):
|
||||||
|
+ self.do_test_with_pip(False)
|
||||||
|
+ self.do_test_with_pip(True)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
||||||
|
diff --git a/Lib/venv/__init__.py b/Lib/venv/__init__.py
|
||||||
|
index 74245ab..fa03262 100644
|
||||||
|
--- a/Lib/venv/__init__.py
|
||||||
|
+++ b/Lib/venv/__init__.py
|
||||||
|
@@ -77,6 +77,10 @@ def create(self, env_dir):
|
||||||
|
"""
|
||||||
|
env_dir = os.path.abspath(env_dir)
|
||||||
|
context = self.ensure_directories(env_dir)
|
||||||
|
+ # See issue 24875. We need system_site_packages to be False
|
||||||
|
+ # until after pip is installed.
|
||||||
|
+ true_system_site_packages = self.system_site_packages
|
||||||
|
+ self.system_site_packages = False
|
||||||
|
self.create_configuration(context)
|
||||||
|
self.setup_python(context)
|
||||||
|
if self.with_pip:
|
||||||
|
@@ -84,6 +88,11 @@ def create(self, env_dir):
|
||||||
|
if not self.upgrade:
|
||||||
|
self.setup_scripts(context)
|
||||||
|
self.post_setup(context)
|
||||||
|
+ if true_system_site_packages:
|
||||||
|
+ # We had set it to False before, now
|
||||||
|
+ # restore it and rewrite the configuration
|
||||||
|
+ self.system_site_packages = True
|
||||||
|
+ self.create_configuration(context)
|
||||||
|
|
||||||
|
def clear_directory(self, path):
|
||||||
|
for fn in os.listdir(path):
|
12
python3.spec
12
python3.spec
|
@ -112,7 +112,7 @@
|
||||||
Summary: Version 3 of the Python programming language aka Python 3000
|
Summary: Version 3 of the Python programming language aka Python 3000
|
||||||
Name: python3
|
Name: python3
|
||||||
Version: %{pybasever}.3
|
Version: %{pybasever}.3
|
||||||
Release: 4%{?dist}
|
Release: 5%{?dist}
|
||||||
License: Python
|
License: Python
|
||||||
Group: Development/Languages
|
Group: Development/Languages
|
||||||
|
|
||||||
|
@ -399,6 +399,11 @@ Patch243: 00243-fix-mips64-triplet.patch
|
||||||
# and tests and integration by Nick Coghlan.
|
# and tests and integration by Nick Coghlan.
|
||||||
Patch259: 00259-tolerate-legacy-invalid-bytecode.patch
|
Patch259: 00259-tolerate-legacy-invalid-bytecode.patch
|
||||||
|
|
||||||
|
# 00267 #
|
||||||
|
# Make pip installable inside a new venv when using the --system-site-packages flag
|
||||||
|
# FIXED UPSTREAM: https://bugs.python.org/issue24875
|
||||||
|
Patch267: 00267-install-pip-in-a-venv-with-system-site-packages.patch
|
||||||
|
|
||||||
# (New patches go here ^^^)
|
# (New patches go here ^^^)
|
||||||
#
|
#
|
||||||
# When adding new patches to "python" and "python3" in Fedora, EL, etc.,
|
# When adding new patches to "python" and "python3" in Fedora, EL, etc.,
|
||||||
|
@ -639,8 +644,8 @@ sed -r -i s/'_PIP_VERSION = "[0-9.]+"'/'_PIP_VERSION = "%{pip_version}"'/ Lib/en
|
||||||
%patch205 -p1
|
%patch205 -p1
|
||||||
%patch206 -p1
|
%patch206 -p1
|
||||||
%patch243 -p1
|
%patch243 -p1
|
||||||
|
|
||||||
%patch259 -p1
|
%patch259 -p1
|
||||||
|
%patch267 -p1
|
||||||
|
|
||||||
# Currently (2010-01-15), http://docs.python.org/library is for 2.6, and there
|
# Currently (2010-01-15), http://docs.python.org/library is for 2.6, and there
|
||||||
# are many differences between 2.6 and the Python 3 library.
|
# are many differences between 2.6 and the Python 3 library.
|
||||||
|
@ -1540,6 +1545,9 @@ rm -fr %{buildroot}
|
||||||
# ======================================================
|
# ======================================================
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Mon Apr 24 2017 Charalampos Stratakis <cstratak@redhat.com> - 3.5.3-5
|
||||||
|
- Make pip installable in a new venv when using the --system-site-packages flag
|
||||||
|
|
||||||
* Tue Mar 21 2017 Tomas Orsava <torsava@redhat.com> - 3.5.3-4
|
* Tue Mar 21 2017 Tomas Orsava <torsava@redhat.com> - 3.5.3-4
|
||||||
- Fix syntax error in %%py_byte_compile macro (rhbz#1433569)
|
- Fix syntax error in %%py_byte_compile macro (rhbz#1433569)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue