Skip to content

Commit 40d2f18

Browse files
authored
Fail early instead of creating non-working env (#2189)
for Python 2 on Apple Silicon (M1) Macs. Related to #2024.
1 parent 9e03c94 commit 40d2f18

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

docs/changelog/2189.misc.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fail early instead of creating a non-working env for Python 2 on Apple Silicon (M1) Macs.

src/virtualenv/create/via_global_ref/builtin/cpython/mac_os.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from six import add_metaclass
1111

1212
from virtualenv.create.via_global_ref.builtin.ref import ExePathRefToDest, PathRefToDest, RefMust
13+
from virtualenv.info import IS_MAC_ARM64
1314
from virtualenv.util.path import Path
1415
from virtualenv.util.six import ensure_text
1516

@@ -102,6 +103,13 @@ def reload_code(self):
102103
)
103104
return result
104105

106+
@classmethod
107+
def can_create(cls, interpreter):
108+
if IS_MAC_ARM64:
109+
return False
110+
else:
111+
return super(CPythonmacOsFramework, cls).can_create(interpreter)
112+
105113

106114
class CPython3macOsFramework(CPythonmacOsFramework, CPython3, CPythonPosix):
107115
@classmethod

src/virtualenv/info.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
PY3 = sys.version_info[0] == 3
1313
PY2 = sys.version_info[0] == 2
1414
IS_WIN = sys.platform == "win32"
15+
IS_MAC_ARM64 = sys.platform == "darwin" and platform.machine() == "arm64"
1516
ROOT = os.path.realpath(os.path.join(os.path.abspath(__file__), os.path.pardir, os.path.pardir))
1617
IS_ZIPAPP = os.path.isfile(ROOT)
1718
WIN_CPYTHON_2 = IS_CPYTHON and IS_WIN and PY2

0 commit comments

Comments
 (0)