-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support Python 2.7 framework-style distributions on macOS 12
virtualenv's trick of adding a symlink to the base Python dylib (`/Library/Frameworks/Python.framework/Versions/2.7/Python`) in the virtualenv root, and rewriting the dependent dylib list of the `<virtualenv>/bin/python` binary with the path of this symlink, no longer works in macOS 12. As of macOS 12, when <https://github.com/python/cpython/blob/v2.7.18/Modules/getpath.c> computes `sys.prefix`, it ends up resolving the symlink. The result is that `sys.prefix` points to the Python framework, e.g. `/path/to/Python.framework/Versions/2.7` instead of at the virtualenv root. To mitigate this, add a _copy_ of the Python dylib into the virtualenv instead of a symlink. To placate code signing (at least on Intel machines), add a symlink to the `Resources` dir so the `Info.plist` file is accessible. Note that Apple's Python 2.7 distribution -- removed in macOS 12.3 but previously located at /System/Library/Frameworks/Python.framework -- behaved differently to the python.org builds. It appears to have incorporated custom patches to getpath.c to support virtualenv. See: <https://github.com/apple-oss-distributions/python/blob/python-170.80.2/2.7/fix/getpath.c.ed>.
- Loading branch information
1 parent
1aa302f
commit 4fb405a
Showing
2 changed files
with
27 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Support for creating a virtual environment from a Python 2.7 framework on macOS 12 - by :user:`nickhutchinson`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters