Skip to content

Commit

Permalink
Fail early instead of creating non-working env
Browse files Browse the repository at this point in the history
for Python 2 on Apple Silicon (M1) Macs.

Related to #2024.
  • Loading branch information
gdubicki authored and gaborbernat committed Sep 20, 2021
1 parent 2151d38 commit ae16371
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/changelog/2189.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fail early instead of creating a non-working env for Python 2 on Apple Silicon (M1) Macs.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from six import add_metaclass

from virtualenv.create.via_global_ref.builtin.ref import ExePathRefToDest, PathRefToDest, RefMust
from virtualenv.info import IS_MAC_ARM64
from virtualenv.util.path import Path
from virtualenv.util.six import ensure_text

Expand Down Expand Up @@ -102,6 +103,13 @@ def reload_code(self):
)
return result

@classmethod
def can_create(cls, interpreter):
if IS_MAC_ARM64:
return False
else:
return super(CPythonmacOsFramework, cls).can_create(interpreter)


class CPython3macOsFramework(CPythonmacOsFramework, CPython3, CPythonPosix):
@classmethod
Expand Down
1 change: 1 addition & 0 deletions src/virtualenv/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
PY3 = sys.version_info[0] == 3
PY2 = sys.version_info[0] == 2
IS_WIN = sys.platform == "win32"
IS_MAC_ARM64 = sys.platform == "darwin" and platform.machine() == "arm64"
ROOT = os.path.realpath(os.path.join(os.path.abspath(__file__), os.path.pardir, os.path.pardir))
IS_ZIPAPP = os.path.isfile(ROOT)
WIN_CPYTHON_2 = IS_CPYTHON and IS_WIN and PY2
Expand Down

0 comments on commit ae16371

Please sign in to comment.