Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ensurepip and pip install failures on macOS Sierra with non-system Python 2.7.x #72626

Open
MarcCuller mannequin opened this issue Oct 14, 2016 · 9 comments
Open

ensurepip and pip install failures on macOS Sierra with non-system Python 2.7.x #72626

MarcCuller mannequin opened this issue Oct 14, 2016 · 9 comments
Assignees

Comments

@MarcCuller
Copy link
Mannequin

MarcCuller mannequin commented Oct 14, 2016

BPO 28440
Nosy @ronaldoussoren, @benjaminp, @ned-deily
PRs
  • bpo-28440: Don't add /Library/Python/3.x/site-packages to sys.path #5445
  • Files
  • pipfails.patch: patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/ned-deily'
    closed_at = None
    created_at = <Date 2016-10-14.13:09:00.573>
    labels = ['OS-mac', '3.7']
    title = 'ensurepip and pip install failures on macOS Sierra with non-system Python 2.7.x'
    updated_at = <Date 2019-07-13.15:23:04.872>
    user = 'https://bugs.python.org/MarcCuller'

    bugs.python.org fields:

    activity = <Date 2019-07-13.15:23:04.872>
    actor = 'ned.deily'
    assignee = 'ned.deily'
    closed = False
    closed_date = None
    closer = None
    components = ['macOS']
    creation = <Date 2016-10-14.13:09:00.573>
    creator = 'Marc.Culler'
    dependencies = []
    files = ['45090']
    hgrepos = []
    issue_num = 28440
    keywords = ['patch']
    message_count = 8.0
    messages = ['278649', '278657', '279779', '282272', '282275', '311261', '347833', '347840']
    nosy_count = 5.0
    nosy_names = ['ronaldoussoren', 'benjamin.peterson', 'ned.deily', 'python-dev', 'Marc.Culler']
    pr_nums = ['5445']
    priority = None
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue28440'
    versions = ['Python 2.7', 'Python 3.6', 'Python 3.7']

    @MarcCuller
    Copy link
    Mannequin Author

    MarcCuller mannequin commented Oct 14, 2016

    Changes made to /Library/Python on macOSX Sierra cause the --with-ensurepip compiler flag to fail, and lead to failures of pip after installing Python.

    The new file that causes the problem on Sierra is:
    /Library/Python/2.7/site-packages/Extras.pth
    The current version of site.py reads that .pth file, which results in sys.path containing the path:
    /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
    The latter directory (which is protected by SIP) contains many Python 2.7 packages, including easy_install, setuptools, six, py2app, numpy, pylab and pyOpenSSL. The effect of including this SIP-protected path in sys.path is this: installing or upgrade a package in /Library/Frameworks/Python.framework which is also installed as an "Extra" in the /System/Frameworks/Python.framework will cause pip to attempt to delete the "old" package from its SIP-protected directory, leading to a "Permission Denied" exception and a failed install.

    Given that Apple has now tied /Library/Python to the system Python in this way, thereby making a separate Python framework in /Library/Frameworks unusable, the natural solution to this problem would be to stop including any /Library/Python paths in sys.path.

    I am attaching a patch that removes the block of code in site.py which adds these paths.

    @MarcCuller MarcCuller mannequin added the build The build process and cross-build label Oct 14, 2016
    @ned-deily
    Copy link
    Member

    This also affects the -m ensurepip installation of pip itself: the pip install fails trying to upgrade the Apple-supplied version of setuptools. The behavior of adding the system Python's site-packages directory to the search path of all framework-build Pythons was deliberately added as a result of bpo-4865. I think experience has shown this was not a good idea because of the coupling it introduced between separate Python installations and some third-party distributors of Python on OS X already patch this code out. It's currently only an issue for 2.7.x since Apple has not yet shipped versions of Python 3.x but the code should be removed there, too.

    @ned-deily ned-deily changed the title pip failures on macOS Sierra ensurepip and pip install failures on macOS Sierra with non-system Python 2.7.x Oct 14, 2016
    @ned-deily ned-deily self-assigned this Oct 14, 2016
    @ned-deily ned-deily removed the build The build process and cross-build label Oct 14, 2016
    @ronaldoussoren
    Copy link
    Contributor

    Another reason to remove this feature: installing python 2.7.12 using the installer on www.python.org breaks the system install of Python, likely because of this issue.

    I'm a bit sad that this feature has to go, but modern Python use (in particular virtualenv) has reduced the need for this feature.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Dec 3, 2016

    New changeset a8a342b3fbc7 by Ned Deily in branch '2.7':
    Issue bpo-28440: No longer add /Library/Python/site-packages, the Apple-supplied
    https://hg.python.org/cpython/rev/a8a342b3fbc7

    @ned-deily
    Copy link
    Member

    I've pushed the change to revert bpo-4865 for the 2.7 branch for release with 2.7.13. I am leaving this open to push similar changes for 3.x branches in anticipation of Apple someday supplying system Python 3.x. It would also be good to see if the post-install script that runs ensurepip can be made to fail more noisily.

    @ned-deily ned-deily added 3.7 (EOL) end of life and removed release-blocker labels Dec 3, 2016
    @ned-deily
    Copy link
    Member

    New changeset 763f094 by Ned Deily in branch 'master':
    bpo-28440: Don't add /Library/Python/3.x/site-packages to sys.path (bpo-5445)
    763f094

    @ronaldoussoren
    Copy link
    Contributor

    In response to msg282272: That day has come, the beta for 10.15 contains Python 3.7.3.

    @ned-deily
    Copy link
    Member

    That day has come, the beta for 10.15 contains Python 3.7.3.

    Yay! FTR, 763f094 was released in 3.7.0.

    The only reason I have left this issues open was that I also wanted to make sure that ensurepip failures in the post-install script do not fail silently.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @ronaldoussoren
    Copy link
    Contributor

    What's left to do for this issue?

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants