Skip to content

Commit 32b3734

Browse files
committed
Issue python#28440: No longer add /Library/Python/site-packages, the Apple-supplied
system Python site-packages directory, to sys.path for macOS framework builds. The coupling between the two Python instances often caused confusion and, as of macOS 10.12, changes to the site-packages layout can cause pip component installations to fail. This change reverts the effects introduced in 2.7.0 by Issue python#4865. If you are using a package with both the Apple system Python 2.7 and a user-installed Python 2.7, you will need to ensure that copies of the package are installed with both Python instances.
1 parent 7653c38 commit 32b3734

File tree

5 files changed

+59
-35
lines changed

5 files changed

+59
-35
lines changed

Doc/whatsnew/2.7.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2343,6 +2343,18 @@ Port-Specific Changes: Mac OS X
23432343
installation and a user-installed copy of the same version.
23442344
(Changed by Ronald Oussoren; :issue:`4865`.)
23452345

2346+
.. versionchanged:: 2.7.13
2347+
2348+
As of 2.7.13, this change was removed.
2349+
``/Library/Python/2.7/site-packages``, the site-packages directory
2350+
used by the Apple-supplied system Python 2.7 is no longer appended to
2351+
``sys.path`` for user-installed Pythons such as from the python.org
2352+
installers. As of macOS 10.12, Apple changed how the system
2353+
site-packages directory is configured, which could cause installation
2354+
of pip components, like setuptools, to fail. Packages installed for
2355+
the system Python will no longer be shared with user-installed
2356+
Pythons. (:issue:`28440`)
2357+
23462358
Port-Specific Changes: FreeBSD
23472359
-----------------------------------
23482360

Lib/site.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -295,15 +295,6 @@ def getsitepackages():
295295
else:
296296
sitepackages.append(prefix)
297297
sitepackages.append(os.path.join(prefix, "lib", "site-packages"))
298-
if sys.platform == "darwin":
299-
# for framework builds *only* we add the standard Apple
300-
# locations.
301-
from sysconfig import get_config_var
302-
framework = get_config_var("PYTHONFRAMEWORK")
303-
if framework:
304-
sitepackages.append(
305-
os.path.join("/Library", framework,
306-
sys.version[:3], "site-packages"))
307298
return sitepackages
308299

309300
def addsitepackages(known_paths):

Lib/test/test_site.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -233,19 +233,8 @@ def test_getsitepackages(self):
233233
self.assertEqual(len(dirs), 1)
234234
wanted = os.path.join('xoxo', 'Lib', 'site-packages')
235235
self.assertEqual(dirs[0], wanted)
236-
elif (sys.platform == "darwin" and
237-
sysconfig.get_config_var("PYTHONFRAMEWORK")):
238-
# OS X framework builds
239-
site.PREFIXES = ['Python.framework']
240-
dirs = site.getsitepackages()
241-
self.assertEqual(len(dirs), 3)
242-
wanted = os.path.join('/Library',
243-
sysconfig.get_config_var("PYTHONFRAMEWORK"),
244-
sys.version[:3],
245-
'site-packages')
246-
self.assertEqual(dirs[2], wanted)
247236
elif os.sep == '/':
248-
# OS X non-framwework builds, Linux, FreeBSD, etc
237+
# OS X, Linux, FreeBSD, etc
249238
self.assertEqual(len(dirs), 2)
250239
wanted = os.path.join('xoxo', 'lib', 'python' + sys.version[:3],
251240
'site-packages')

Mac/BuildScript/resources/ReadMe.rtf

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
{\rtf1\ansi\ansicpg1252\cocoartf1347\cocoasubrtf570
1+
{\rtf1\ansi\ansicpg1252\cocoartf1504\cocoasubrtf750
22
{\fonttbl\f0\fswiss\fcharset0 Helvetica;\f1\fmodern\fcharset0 CourierNewPSMT;}
33
{\colortbl;\red255\green255\blue255;}
4+
{\*\expandedcolortbl;;}
45
\margl1440\margr1440\vieww15240\viewh15540\viewkind0
5-
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural
6+
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
67

78
\f0\fs24 \cf0 This package will install Python $FULL_VERSION for Mac OS X $MACOSX_DEPLOYMENT_TARGET for the following architecture(s): $ARCHITECTURES.\
89
\
9-
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural
10+
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
1011

1112
\b \cf0 \ul \ulc0 Which installer variant should I use?
1213
\b0 \ulnone \
@@ -36,19 +37,37 @@ To use IDLE or other programs that use the Tkinter graphical user interface tool
3637
\i0 for this version of Python and of Mac OS X.\
3738

3839
\b \ul \
39-
Installing on OS X 10.8 (Mountain Lion) or later systems\
40-
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural
40+
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
41+
\cf0 Packages installed with the system Python 2.7 are no longer searched for\
42+
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
43+
\cf0 \ulnone [CHANGED for Python 2.7.13]
44+
\b0 \
45+
\
46+
As of Python 2.7.0, user-installed Python 2.7 versions from python.org installers added the system-wide site-packages directory for the Apple-supplied Python 2.7 to the end of their search path. This meant that packages installed with the system Python 2.7 could also be used by the user-installed Python 2.7. While sometimes convenient, this also often caused confusion with the implicit coupling between the two Python instances. Separately, as of macOS 10.12, Apple changed the layout of the system site-packages directory,
47+
\f1 /Library/Python/2.7/site-packages
48+
\f0 , in a way that can now cause installation of
49+
\f1 pip
50+
\f0 components to fail. To avoid the confusion and the installation failures, as of 2.7.13 user-installed Pythons no longer add
51+
\f1 /Library/Python/2.7/site-packages
52+
\f0 to
53+
\f1 sys.path
54+
\f0 . If you are using a package with both a user-installed Python 2.7 and the system Python 2.7, you will now need to ensure that separate copies of the package are installed for each instance.\
55+
\
56+
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
57+
58+
\b \cf0 \ul Installing on OS X 10.8 (Mountain Lion) or later systems\
59+
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
4160
\cf0 \ulnone [CHANGED for Python 2.7.9]
4261
\b0 \
4362
\
4463
As of Python 2.7.9, installer packages from python.org are now compatible with the Gatekeeper security feature introduced in OS X 10.8. Downloaded packages can now be directly installed by double-clicking with the default system security settings. Python.org installer packages for OS X are signed with the Developer ID of the builder, as identified on {\field{\*\fldinst{HYPERLINK "https://www.python.org/downloads/"}}{\fldrslt the download page}} for this release. To inspect the digital signature of the package, click on the lock icon in the upper right corner of the
4564
\i Install Python
4665
\i0 installer window. Refer to Apple\'92s support pages for {\field{\*\fldinst{HYPERLINK "http://support.apple.com/kb/ht5290"}}{\fldrslt more information on Gatekeeper}}.\
4766
\
48-
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural
67+
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
4968

5069
\b \cf0 \ul Simplified web-based installs\
51-
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural
70+
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
5271
\cf0 \ulnone [NEW for Python 2.7.9]
5372
\b0 \
5473
\
@@ -58,10 +77,10 @@ With the change to the newer flat format installer package, the download file no
5877
\f1 .dmg
5978
\f0 ) container. If you download the Python installer through a web browser, the OS X installer application may open automatically to allow you to perform the install. If your browser settings do not allow automatic open, double click on the downloaded installer file.\
6079
\
61-
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural
80+
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
6281

6382
\b \cf0 \ul New Installation Options and Defaults\
64-
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural
83+
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
6584
\cf0 \ulnone [NEW for Python 2.7.9]
6685
\b0 \
6786
\
@@ -77,10 +96,10 @@ The Python installer now includes an option to automatically install or upgrade
7796
\i Release Notes
7897
\i0 link for this release at {\field{\*\fldinst{HYPERLINK "https://www.python.org/downloads/"}}{\fldrslt https://www.python.org/downloads/}}.\
7998
\
80-
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural
99+
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
81100

82101
\b \cf0 \ul Certificate verification and OpenSSL\
83-
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural
102+
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
84103
\cf0 \ulnone [CHANGED for Python 2.7.9]
85104
\b0 \
86105
\
@@ -132,17 +151,17 @@ For OS X 10.6+, Apple also provides
132151
The bundled
133152
\f1 pip
134153
\f0 included with 2.7.9 has its own default certificate store for verifying download connections.\
135-
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural
154+
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
136155

137156
\b \cf0 \ul \
138157
Binary installer support for OS X 10.4 and 10.3.9 discontinued\
139-
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural
158+
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
140159
\cf0 \ulnone [CHANGED for Python 2.7.9]
141160
\b0 \
142161
\
143162
As previously announced, binary installers for Python 2.7.9 from python.org no longer support Mac OS X 10.3.9 (Panther) and 10.4.x (Tiger) systems. These systems were last updated by Apple in 2005 and 2007. As of 2.7.9, the 32-bit-only installer supports PPC and Intel Macs running OS X 10.5 (Leopard). 10.5 was the last OS X release for PPC machines (G4 and G5). The 64-/32-bit installer configuration remains unchanged and should normally be used on OS X 10.6 (Snow Leopard) and later systems. This aligns Python 2.7.x installer configurations with those currently provided with Python 3.x. If needed, it is still possible to build Python from source for 10.3.9 and 10.4.\
144163
\
145-
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural
164+
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
146165

147166
\b \cf0 \ul Python 3 and Python 2 Co-existence\
148167

Misc/NEWS

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,19 @@ Windows
336336
- Issue #27888: Prevent Windows installer from displaying console windows and
337337
failing when pip cannot be installed/uninstalled.
338338

339+
Mac OS X
340+
--------
341+
342+
- Issue #28440: No longer add /Library/Python/site-packages, the Apple-supplied
343+
system Python site-packages directory, to sys.path for macOS framework builds.
344+
The coupling between the two Python instances often caused confusion and, as
345+
of macOS 10.12, changes to the site-packages layout can cause pip component
346+
installations to fail. This change reverts the effects introduced in 2.7.0
347+
by Issue #4865. If you are using a package with both the Apple system Python
348+
2.7 and a user-installed Python 2.7, you will need to ensure that copies of
349+
the package are installed with both Python instances.
350+
351+
339352
What's New in Python 2.7.12?
340353
============================
341354

0 commit comments

Comments
 (0)