bpo-44009: Provide "python3.x-intel64" for Apple Silicon Macs (GH-25804)

This allows reliably forcing macOS universal2 framework builds
to run under Rosetta 2 Intel-64 emulation on Apple Silicon Macs
if needed for testing or when universal2 wheels are not yet
available.
This commit is contained in:
Ned Deily 2021-05-02 04:48:29 -04:00 committed by GitHub
parent 91554e4c5c
commit 0cb33da1cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 62 additions and 9 deletions

View File

@ -20,6 +20,7 @@ FRAMEWORKUNIXTOOLSPREFIX=@FRAMEWORKUNIXTOOLSPREFIX@
PYTHONFRAMEWORK=@PYTHONFRAMEWORK@ PYTHONFRAMEWORK=@PYTHONFRAMEWORK@
PYTHONFRAMEWORKIDENTIFIER=@PYTHONFRAMEWORKIDENTIFIER@ PYTHONFRAMEWORKIDENTIFIER=@PYTHONFRAMEWORKIDENTIFIER@
LIPO_32BIT_FLAGS=@LIPO_32BIT_FLAGS@ LIPO_32BIT_FLAGS=@LIPO_32BIT_FLAGS@
LIPO_INTEL64_FLAGS=@LIPO_INTEL64_FLAGS@
CC=@CC@ CC=@CC@
MACOSX_DEPLOYMENT_TARGET=@CONFIGURE_MACOSX_DEPLOYMENT_TARGET@ MACOSX_DEPLOYMENT_TARGET=@CONFIGURE_MACOSX_DEPLOYMENT_TARGET@
export MACOSX_DEPLOYMENT_TARGET export MACOSX_DEPLOYMENT_TARGET
@ -92,6 +93,16 @@ installunixtools:
$(LN) -s $(BINDIR)/$${fn} $${fn} ;\ $(LN) -s $(BINDIR)/$${fn} $${fn} ;\
done ;\ done ;\
fi fi
-if test "x$(LIPO_INTEL64_FLAGS)" != "x"; then \
cd "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" && \
for fn in \
python3-intel64 \
; \
do \
rm -f $${fn} ;\
$(LN) -s $(BINDIR)/$${fn} $${fn} ;\
done ;\
fi
-if test "x$(ENSUREPIP)" != "xno" ; then \ -if test "x$(ENSUREPIP)" != "xno" ; then \
cd "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" && \ cd "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" && \
for fn in \ for fn in \
@ -142,6 +153,16 @@ altinstallunixtools:
$(LN) -s $(BINDIR)/$${fn} $${fn} ;\ $(LN) -s $(BINDIR)/$${fn} $${fn} ;\
done ;\ done ;\
fi fi
-if test "x$(LIPO_INTEL64_FLAGS)" != "x"; then \
cd "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" && \
for fn in \
python$(VERSION)-intel64 \
; \
do \
rm -f $${fn} ;\
$(LN) -s $(BINDIR)/$${fn} $${fn} ;\
done ;\
fi
-if test "x$(ENSUREPIP)" != "xno" ; then \ -if test "x$(ENSUREPIP)" != "xno" ; then \
cd "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" && \ cd "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" && \
for fn in \ for fn in \

View File

@ -162,6 +162,9 @@ following combinations of SDKs and universal-archs flavors are available:
The makefile for a framework build will also install ``python3.x-32`` The makefile for a framework build will also install ``python3.x-32``
binaries when the universal architecture includes at least one 32-bit binaries when the universal architecture includes at least one 32-bit
architecture (that is, for all flavors but ``64-bit`` and ``intel-64``). architecture (that is, for all flavors but ``64-bit`` and ``intel-64``).
It will also install ``python3.x-intel64`` binaries in the ``universal2``
case to allow easy execution with the Rosetta 2 Intel emulator on Apple
Silicon Macs.
Running a specific architecture Running a specific architecture
............................... ...............................
@ -181,6 +184,9 @@ subprocesses also run in 32-bit-mode if the main interpreter does, use
a ``python3.x-32`` binary and use the value of ``sys.executable`` as the a ``python3.x-32`` binary and use the value of ``sys.executable`` as the
``subprocess`` ``Popen`` executable value. ``subprocess`` ``Popen`` executable value.
Likewise, use ``python3.x-intel64`` to force execution in ``x86_64`` mode
with ``universal2`` binaries.
Building and using a framework-based Python on macOS Building and using a framework-based Python on macOS
==================================================== ====================================================

View File

@ -189,6 +189,9 @@ STRIPFLAG=-s
# Flags to lipo to produce a 32-bit-only universal executable # Flags to lipo to produce a 32-bit-only universal executable
LIPO_32BIT_FLAGS=@LIPO_32BIT_FLAGS@ LIPO_32BIT_FLAGS=@LIPO_32BIT_FLAGS@
# Flags to lipo to produce an intel-64-only universal executable
LIPO_INTEL64_FLAGS=@LIPO_INTEL64_FLAGS@
# Options to enable prebinding (for fast startup prior to Mac OS X 10.3) # Options to enable prebinding (for fast startup prior to Mac OS X 10.3)
OTHER_LIBTOOL_OPT=@OTHER_LIBTOOL_OPT@ OTHER_LIBTOOL_OPT=@OTHER_LIBTOOL_OPT@
@ -1344,6 +1347,12 @@ altbininstall: $(BUILDPYTHON) @FRAMEWORKPYTHONW@
-output $(DESTDIR)$(BINDIR)/python$(VERSION)-32$(EXE) \ -output $(DESTDIR)$(BINDIR)/python$(VERSION)-32$(EXE) \
$(DESTDIR)$(BINDIR)/python$(VERSION)$(EXE); \ $(DESTDIR)$(BINDIR)/python$(VERSION)$(EXE); \
fi fi
if test "x$(LIPO_INTEL64_FLAGS)" != "x" ; then \
rm -f $(DESTDIR)$(BINDIR)python$(VERSION)-intel64$(EXE); \
lipo $(LIPO_INTEL64_FLAGS) \
-output $(DESTDIR)$(BINDIR)/python$(VERSION)-intel64$(EXE) \
$(DESTDIR)$(BINDIR)/python$(VERSION)$(EXE); \
fi
bininstall: altbininstall bininstall: altbininstall
if test ! -d $(DESTDIR)$(LIBPC); then \ if test ! -d $(DESTDIR)$(LIBPC); then \
@ -1379,6 +1388,10 @@ bininstall: altbininstall
rm -f $(DESTDIR)$(BINDIR)/python3-32$(EXE); \ rm -f $(DESTDIR)$(BINDIR)/python3-32$(EXE); \
(cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)-32$(EXE) python3-32$(EXE)) \ (cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)-32$(EXE) python3-32$(EXE)) \
fi fi
if test "x$(LIPO_INTEL64_FLAGS)" != "x" ; then \
rm -f $(DESTDIR)$(BINDIR)/python3-intel64$(EXE); \
(cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)-intel64$(EXE) python3-intel64$(EXE)) \
fi
# Install the versioned manual page # Install the versioned manual page
altmaninstall: altmaninstall:

View File

@ -0,0 +1,4 @@
Provide "python3.x-intel64" executable to allow reliably forcing macOS
universal2 framework builds to run under Rosetta 2 Intel-64 emulation on
Apple Silicon Macs. This can be useful for testing or when universal2
wheels are not yet available.

15
configure vendored
View File

@ -752,6 +752,7 @@ PYTHONFRAMEWORKPREFIX
PYTHONFRAMEWORKDIR PYTHONFRAMEWORKDIR
PYTHONFRAMEWORKIDENTIFIER PYTHONFRAMEWORKIDENTIFIER
PYTHONFRAMEWORK PYTHONFRAMEWORK
LIPO_INTEL64_FLAGS
LIPO_32BIT_FLAGS LIPO_32BIT_FLAGS
ARCH_RUN_32BIT ARCH_RUN_32BIT
UNIVERSALSDK UNIVERSALSDK
@ -1519,11 +1520,12 @@ Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--with-universal-archs=ARCH --with-universal-archs=ARCH
specify the kind of universal binary that should be specify the kind of macOS universal binary that
created. this option is only valid when should be created. This option is only valid when
--enable-universalsdk is set; options are: --enable-universalsdk is set; options are:
("universal2", "32-bit", "64-bit", "3-way", "intel", ("universal2", "intel-64", "intel-32", "intel",
"intel-32", "intel-64", or "all") see Mac/README.rst "32-bit", "64-bit", "3-way", or "all") see
Mac/README.rst
--with-framework-name=FRAMEWORK --with-framework-name=FRAMEWORK
specify the name for the python framework on macOS specify the name for the python framework on macOS
only valid when --enable-framework is set. see only valid when --enable-framework is set. see
@ -3139,6 +3141,7 @@ then
fi fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-universal-archs" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-universal-archs" >&5
$as_echo_n "checking for --with-universal-archs... " >&6; } $as_echo_n "checking for --with-universal-archs... " >&6; }
@ -7522,6 +7525,7 @@ $as_echo_n "checking which compiler should be used... " >&6; }
$as_echo "$CC" >&6; } $as_echo "$CC" >&6; }
fi fi
LIPO_INTEL64_FLAGS=""
if test "${enable_universalsdk}" if test "${enable_universalsdk}"
then then
case "$UNIVERSAL_ARCHS" in case "$UNIVERSAL_ARCHS" in
@ -7543,8 +7547,9 @@ $as_echo "$CC" >&6; }
universal2) universal2)
UNIVERSAL_ARCH_FLAGS="-arch arm64 -arch x86_64" UNIVERSAL_ARCH_FLAGS="-arch arm64 -arch x86_64"
LIPO_32BIT_FLAGS="" LIPO_32BIT_FLAGS=""
LIPO_INTEL64_FLAGS="-extract x86_64"
ARCH_RUN_32BIT="true" ARCH_RUN_32BIT="true"
;; ;;
intel) intel)
UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64" UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64"
LIPO_32BIT_FLAGS="-extract i386" LIPO_32BIT_FLAGS="-extract i386"

View File

@ -220,12 +220,14 @@ then
fi fi
AC_SUBST(LIPO_32BIT_FLAGS) AC_SUBST(LIPO_32BIT_FLAGS)
AC_SUBST(LIPO_INTEL64_FLAGS)
AC_MSG_CHECKING(for --with-universal-archs) AC_MSG_CHECKING(for --with-universal-archs)
AC_ARG_WITH(universal-archs, AC_ARG_WITH(universal-archs,
AS_HELP_STRING([--with-universal-archs=ARCH], AS_HELP_STRING([--with-universal-archs=ARCH],
[specify the kind of universal binary that should be created. this option is [specify the kind of macOS universal binary that should be created.
only valid when --enable-universalsdk is set; options are: This option is only valid when --enable-universalsdk is set; options are:
("universal2", "32-bit", "64-bit", "3-way", "intel", "intel-32", "intel-64", or "all") ("universal2", "intel-64", "intel-32", "intel", "32-bit",
"64-bit", "3-way", or "all")
see Mac/README.rst]), see Mac/README.rst]),
[ [
UNIVERSAL_ARCHS="$withval" UNIVERSAL_ARCHS="$withval"
@ -1874,6 +1876,7 @@ yes)
AC_MSG_RESULT($CC) AC_MSG_RESULT($CC)
fi fi
LIPO_INTEL64_FLAGS=""
if test "${enable_universalsdk}" if test "${enable_universalsdk}"
then then
case "$UNIVERSAL_ARCHS" in case "$UNIVERSAL_ARCHS" in
@ -1895,8 +1898,9 @@ yes)
universal2) universal2)
UNIVERSAL_ARCH_FLAGS="-arch arm64 -arch x86_64" UNIVERSAL_ARCH_FLAGS="-arch arm64 -arch x86_64"
LIPO_32BIT_FLAGS="" LIPO_32BIT_FLAGS=""
LIPO_INTEL64_FLAGS="-extract x86_64"
ARCH_RUN_32BIT="true" ARCH_RUN_32BIT="true"
;; ;;
intel) intel)
UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64" UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64"
LIPO_32BIT_FLAGS="-extract i386" LIPO_32BIT_FLAGS="-extract i386"