[Python-checkins] bpo-28440: Don't add /Library/Python/3.x/site-packages to sys.path (#5445)

Ned Deily webhook-mailer at python.org
Tue Jan 30 05:14:15 EST 2018


https://github.com/python/cpython/commit/763f094b1f0ce2a07768828e78afe9687e9ad3bb
commit: 763f094b1f0ce2a07768828e78afe9687e9ad3bb
branch: master
author: Ned Deily <nad at python.org>
committer: GitHub <noreply at github.com>
date: 2018-01-30T05:14:09-05:00
summary:

bpo-28440: Don't add /Library/Python/3.x/site-packages to sys.path (#5445)

No longer add /Library/Python/3.x/site-packages, the Apple-supplied
system Python site-packages directory, to sys.path for macOS framework
builds in case Apple ships a version of Python 3. A similar change
was made earlier to Python 2.7 where it was found that the coupling
between the system Python and a user-installed framework Python often
caused confusion or pip install failures.

files:
A Misc/NEWS.d/next/macOS/2018-01-30-04-40-12.bpo-28440.W_BUWU.rst
M Lib/site.py
M Lib/test/test_site.py

diff --git a/Lib/site.py b/Lib/site.py
index 7dc1b041c192..950e7038a505 100644
--- a/Lib/site.py
+++ b/Lib/site.py
@@ -340,11 +340,6 @@ def getsitepackages(prefixes=None):
         else:
             sitepackages.append(prefix)
             sitepackages.append(os.path.join(prefix, "lib", "site-packages"))
-        # for framework builds *only* we add the standard Apple locations.
-        if sys.platform == "darwin" and sys._framework:
-            sitepackages.append(
-                os.path.join("/Library", sys._framework,
-                             '%d.%d' % sys.version_info[:2], "site-packages"))
     return sitepackages
 
 def addsitepackages(known_paths, prefixes=None):
diff --git a/Lib/test/test_site.py b/Lib/test/test_site.py
index 266adf01e04d..b6648d67ca68 100644
--- a/Lib/test/test_site.py
+++ b/Lib/test/test_site.py
@@ -261,20 +261,8 @@ def test_getusersitepackages(self):
     def test_getsitepackages(self):
         site.PREFIXES = ['xoxo']
         dirs = site.getsitepackages()
-
-        if (sys.platform == "darwin" and
-            sysconfig.get_config_var("PYTHONFRAMEWORK")):
-            # OS X framework builds
-            site.PREFIXES = ['Python.framework']
-            dirs = site.getsitepackages()
-            self.assertEqual(len(dirs), 2)
-            wanted = os.path.join('/Library',
-                                  sysconfig.get_config_var("PYTHONFRAMEWORK"),
-                                  '%d.%d' % sys.version_info[:2],
-                                  'site-packages')
-            self.assertEqual(dirs[1], wanted)
-        elif os.sep == '/':
-            # OS X non-framework builds, Linux, FreeBSD, etc
+        if os.sep == '/':
+            # OS X, Linux, FreeBSD, etc
             self.assertEqual(len(dirs), 1)
             wanted = os.path.join('xoxo', 'lib',
                                   'python%d.%d' % sys.version_info[:2],
diff --git a/Misc/NEWS.d/next/macOS/2018-01-30-04-40-12.bpo-28440.W_BUWU.rst b/Misc/NEWS.d/next/macOS/2018-01-30-04-40-12.bpo-28440.W_BUWU.rst
new file mode 100644
index 000000000000..e973e0957755
--- /dev/null
+++ b/Misc/NEWS.d/next/macOS/2018-01-30-04-40-12.bpo-28440.W_BUWU.rst
@@ -0,0 +1,2 @@
+No longer add /Library/Python/3.x/site-packages to sys.path for macOS
+framework builds to avoid future conflicts.



More information about the Python-checkins mailing list