summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNicholas Hutchinson <nshutchinson@gmail.com>2022-04-11 08:54:23 +0100
committerGitHub <noreply@github.com>2022-04-11 08:54:23 +0100
commit63e80ff9cb3adb16420d2010c8d43eca9082d1d3 (patch)
treebf7474e7a999d0dd4fce18f8beba966317646092 /src
parent8c950c22c1bf350b817eea4919f65d499b8c3c26 (diff)
downloadvirtualenv-63e80ff9cb3adb16420d2010c8d43eca9082d1d3.tar.gz
Support Python 2.7 framework-style distributions on macOS 12 (#2325)
Diffstat (limited to 'src')
-rw-r--r--src/virtualenv/create/via_global_ref/builtin/cpython/mac_os.py46
1 files changed, 26 insertions, 20 deletions
diff --git a/src/virtualenv/create/via_global_ref/builtin/cpython/mac_os.py b/src/virtualenv/create/via_global_ref/builtin/cpython/mac_os.py
index 6024c97..d64f0d9 100644
--- a/src/virtualenv/create/via_global_ref/builtin/cpython/mac_os.py
+++ b/src/virtualenv/create/via_global_ref/builtin/cpython/mac_os.py
@@ -25,20 +25,11 @@ class CPythonmacOsFramework(CPython):
def can_describe(cls, interpreter):
return is_mac_os_framework(interpreter) and super(CPythonmacOsFramework, cls).can_describe(interpreter)
- @classmethod
- def sources(cls, interpreter):
- for src in super(CPythonmacOsFramework, cls).sources(interpreter):
- yield src
- # add a symlink to the host python image
- exe = cls.image_ref(interpreter)
- ref = PathRefToDest(exe, dest=lambda self, _: self.dest / ".Python", must=RefMust.SYMLINK)
- yield ref
-
def create(self):
super(CPythonmacOsFramework, self).create()
# change the install_name of the copied python executables
- target = "@executable_path/../.Python"
+ target = self.desired_mach_o_image_path()
current = self.current_mach_o_image_path()
for src in self._sources:
if isinstance(src, ExePathRefToDest):
@@ -62,8 +53,8 @@ class CPythonmacOsFramework(CPython):
def current_mach_o_image_path(self):
raise NotImplementedError
- @classmethod
- def image_ref(cls, interpreter):
+ @abstractmethod
+ def desired_mach_o_image_path(self):
raise NotImplementedError
@@ -74,13 +65,12 @@ class CPython2macOsFramework(CPythonmacOsFramework, CPython2PosixBase):
return super(CPython2macOsFramework, cls).can_create(interpreter)
return False
- @classmethod
- def image_ref(cls, interpreter):
- return Path(interpreter.prefix) / "Python"
-
def current_mach_o_image_path(self):
return os.path.join(self.interpreter.prefix, "Python")
+ def desired_mach_o_image_path(self):
+ return "@executable_path/../Python"
+
@classmethod
def sources(cls, interpreter):
for src in super(CPython2macOsFramework, cls).sources(interpreter):
@@ -89,6 +79,14 @@ class CPython2macOsFramework(CPythonmacOsFramework, CPython2PosixBase):
exec_marker_file, to_path, _ = cls.from_stdlib(cls.mappings(interpreter), "lib-dynload")
yield PathRefToDest(exec_marker_file, dest=to_path)
+ # add a copy of the host python image
+ exe = Path(interpreter.prefix) / "Python"
+ yield PathRefToDest(exe, dest=lambda self, _: self.dest / "Python", must=RefMust.COPY)
+
+ # add a symlink to the Resources dir
+ resources = Path(interpreter.prefix) / "Resources"
+ yield PathRefToDest(resources, dest=lambda self, _: self.dest / "Resources")
+
@property
def reload_code(self):
result = super(CPython2macOsFramework, self).reload_code
@@ -147,13 +145,21 @@ class CPython2macOsArmFramework(CPython2macOsFramework, CPythonmacOsFramework, C
class CPython3macOsFramework(CPythonmacOsFramework, CPython3, CPythonPosix):
- @classmethod
- def image_ref(cls, interpreter):
- return Path(interpreter.prefix) / "Python3"
-
def current_mach_o_image_path(self):
return "@executable_path/../../../../Python3"
+ def desired_mach_o_image_path(self):
+ return "@executable_path/../.Python"
+
+ @classmethod
+ def sources(cls, interpreter):
+ for src in super(CPython3macOsFramework, cls).sources(interpreter):
+ yield src
+
+ # add a symlink to the host python image
+ exe = Path(interpreter.prefix) / "Python3"
+ yield PathRefToDest(exe, dest=lambda self, _: self.dest / ".Python", must=RefMust.SYMLINK)
+
@property
def reload_code(self):
result = super(CPython3macOsFramework, self).reload_code