Skip to content

Commit 763f094

Browse files
authored
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.
1 parent 67adb31 commit 763f094

File tree

3 files changed

+4
-19
lines changed

3 files changed

+4
-19
lines changed

Lib/site.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -340,11 +340,6 @@ def getsitepackages(prefixes=None):
340340
else:
341341
sitepackages.append(prefix)
342342
sitepackages.append(os.path.join(prefix, "lib", "site-packages"))
343-
# for framework builds *only* we add the standard Apple locations.
344-
if sys.platform == "darwin" and sys._framework:
345-
sitepackages.append(
346-
os.path.join("/Library", sys._framework,
347-
'%d.%d' % sys.version_info[:2], "site-packages"))
348343
return sitepackages
349344

350345
def addsitepackages(known_paths, prefixes=None):

Lib/test/test_site.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -261,20 +261,8 @@ def test_getusersitepackages(self):
261261
def test_getsitepackages(self):
262262
site.PREFIXES = ['xoxo']
263263
dirs = site.getsitepackages()
264-
265-
if (sys.platform == "darwin" and
266-
sysconfig.get_config_var("PYTHONFRAMEWORK")):
267-
# OS X framework builds
268-
site.PREFIXES = ['Python.framework']
269-
dirs = site.getsitepackages()
270-
self.assertEqual(len(dirs), 2)
271-
wanted = os.path.join('/Library',
272-
sysconfig.get_config_var("PYTHONFRAMEWORK"),
273-
'%d.%d' % sys.version_info[:2],
274-
'site-packages')
275-
self.assertEqual(dirs[1], wanted)
276-
elif os.sep == '/':
277-
# OS X non-framework builds, Linux, FreeBSD, etc
264+
if os.sep == '/':
265+
# OS X, Linux, FreeBSD, etc
278266
self.assertEqual(len(dirs), 1)
279267
wanted = os.path.join('xoxo', 'lib',
280268
'python%d.%d' % sys.version_info[:2],
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
No longer add /Library/Python/3.x/site-packages to sys.path for macOS
2+
framework builds to avoid future conflicts.

0 commit comments

Comments
 (0)