Unverified Kaydet (Commit) 763f094b authored tarafından Ned Deily's avatar Ned Deily Kaydeden (comit) GitHub

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.
üst 67adb31a
...@@ -340,11 +340,6 @@ def getsitepackages(prefixes=None): ...@@ -340,11 +340,6 @@ def getsitepackages(prefixes=None):
else: else:
sitepackages.append(prefix) sitepackages.append(prefix)
sitepackages.append(os.path.join(prefix, "lib", "site-packages")) 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 return sitepackages
def addsitepackages(known_paths, prefixes=None): def addsitepackages(known_paths, prefixes=None):
......
...@@ -261,20 +261,8 @@ class HelperFunctionsTests(unittest.TestCase): ...@@ -261,20 +261,8 @@ class HelperFunctionsTests(unittest.TestCase):
def test_getsitepackages(self): def test_getsitepackages(self):
site.PREFIXES = ['xoxo'] site.PREFIXES = ['xoxo']
dirs = site.getsitepackages() dirs = site.getsitepackages()
if os.sep == '/':
if (sys.platform == "darwin" and # OS X, Linux, FreeBSD, etc
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
self.assertEqual(len(dirs), 1) self.assertEqual(len(dirs), 1)
wanted = os.path.join('xoxo', 'lib', wanted = os.path.join('xoxo', 'lib',
'python%d.%d' % sys.version_info[:2], 'python%d.%d' % sys.version_info[:2],
......
No longer add /Library/Python/3.x/site-packages to sys.path for macOS
framework builds to avoid future conflicts.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment