[Python-checkins] bpo-44009: Provide "python3.x-intel64" for Apple Silicon Macs (GH-25810)
ned-deily
webhook-mailer at python.org
Sun May 2 06:55:08 EDT 2021
https://github.com/python/cpython/commit/78e55888ab379cc61c0b5db67f0b881e526628d2
commit: 78e55888ab379cc61c0b5db67f0b881e526628d2
branch: 3.8
author: Ned Deily <nad at python.org>
committer: ned-deily <nad at python.org>
date: 2021-05-02T06:55:04-04:00
summary:
bpo-44009: Provide "python3.x-intel64" for Apple Silicon Macs (GH-25810)
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.
(cherry picked from commit 0cb33da1cc9cebb9b2d67d446feb1cfd36fe7f55)
Co-authored-by: Ned Deily <nad at python.org>
Automerge-Triggered-By: GH:ned-deily
Co-authored-by: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
files:
A Misc/NEWS.d/next/macOS/2021-05-02-03-45-30.bpo-44009.uvhmlh.rst
M Mac/Makefile.in
M Mac/README.rst
M Makefile.pre.in
M configure
M configure.ac
diff --git a/Mac/Makefile.in b/Mac/Makefile.in
index 0b32673323a0d..f969128841453 100644
--- a/Mac/Makefile.in
+++ b/Mac/Makefile.in
@@ -20,6 +20,7 @@ FRAMEWORKUNIXTOOLSPREFIX=@FRAMEWORKUNIXTOOLSPREFIX@
PYTHONFRAMEWORK=@PYTHONFRAMEWORK@
PYTHONFRAMEWORKIDENTIFIER=@PYTHONFRAMEWORKIDENTIFIER@
LIPO_32BIT_FLAGS=@LIPO_32BIT_FLAGS@
+LIPO_INTEL64_FLAGS=@LIPO_INTEL64_FLAGS@
CC=@CC@
MACOSX_DEPLOYMENT_TARGET=@CONFIGURE_MACOSX_DEPLOYMENT_TARGET@
export MACOSX_DEPLOYMENT_TARGET
@@ -92,6 +93,16 @@ installunixtools:
$(LN) -s $(BINDIR)/$${fn} $${fn} ;\
done ;\
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 \
cd "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" && \
for fn in \
@@ -142,6 +153,16 @@ altinstallunixtools:
$(LN) -s $(BINDIR)/$${fn} $${fn} ;\
done ;\
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 \
cd "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" && \
for fn in \
diff --git a/Mac/README.rst b/Mac/README.rst
index f63a424ad10d8..d455a0a24e535 100644
--- a/Mac/README.rst
+++ b/Mac/README.rst
@@ -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``
binaries when the universal architecture includes at least one 32-bit
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
...............................
@@ -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
``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
====================================================
diff --git a/Makefile.pre.in b/Makefile.pre.in
index c328d35beb81d..7e381283fee88 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -182,6 +182,9 @@ STRIPFLAG=-s
# Flags to lipo to produce a 32-bit-only universal executable
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)
OTHER_LIBTOOL_OPT=@OTHER_LIBTOOL_OPT@
@@ -1267,6 +1270,12 @@ altbininstall: $(BUILDPYTHON) @FRAMEWORKPYTHONW@
-output $(DESTDIR)$(BINDIR)/python$(VERSION)-32$(EXE) \
$(DESTDIR)$(BINDIR)/python$(VERSION)$(EXE); \
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
if test ! -d $(DESTDIR)$(LIBPC); then \
@@ -1302,6 +1311,10 @@ bininstall: altbininstall
rm -f $(DESTDIR)$(BINDIR)/python3-32$(EXE); \
(cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)-32$(EXE) python3-32$(EXE)) \
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
altmaninstall:
diff --git a/Misc/NEWS.d/next/macOS/2021-05-02-03-45-30.bpo-44009.uvhmlh.rst b/Misc/NEWS.d/next/macOS/2021-05-02-03-45-30.bpo-44009.uvhmlh.rst
new file mode 100644
index 0000000000000..f9f11c8ae6a79
--- /dev/null
+++ b/Misc/NEWS.d/next/macOS/2021-05-02-03-45-30.bpo-44009.uvhmlh.rst
@@ -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.
diff --git a/configure b/configure
index d1a61d86ee5ce..936f3d4596f53 100755
--- a/configure
+++ b/configure
@@ -742,6 +742,7 @@ PYTHONFRAMEWORKPREFIX
PYTHONFRAMEWORKDIR
PYTHONFRAMEWORKIDENTIFIER
PYTHONFRAMEWORK
+LIPO_INTEL64_FLAGS
LIPO_32BIT_FLAGS
ARCH_RUN_32BIT
UNIVERSALSDK
@@ -1490,9 +1491,12 @@ Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--with-universal-archs=ARCH
- select architectures for universal build ("32-bit",
- "64-bit", "3-way", "intel", "intel-32", "intel-64",
- "universal2", or "all")
+ specify the kind of macOS universal binary that
+ should be created. This option is only valid when
+ --enable-universalsdk is set; options are:
+ ("universal2", "intel-64", "intel-32", "intel",
+ "32-bit", "64-bit", "3-way", or "all") see
+ Mac/README.rst
--with-framework-name=FRAMEWORK
specify an alternate name of the framework built
with --enable-framework
@@ -3073,6 +3077,7 @@ then
fi
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-universal-archs" >&5
$as_echo_n "checking for --with-universal-archs... " >&6; }
@@ -7373,6 +7378,7 @@ $as_echo_n "checking which compiler should be used... " >&6; }
$as_echo "$CC" >&6; }
fi
+ LIPO_INTEL64_FLAGS=""
if test "${enable_universalsdk}"
then
case "$UNIVERSAL_ARCHS" in
@@ -7394,8 +7400,9 @@ $as_echo "$CC" >&6; }
universal2)
UNIVERSAL_ARCH_FLAGS="-arch arm64 -arch x86_64"
LIPO_32BIT_FLAGS=""
+ LIPO_INTEL64_FLAGS="-extract x86_64"
ARCH_RUN_32BIT="true"
- ;;
+ ;;
intel)
UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64"
LIPO_32BIT_FLAGS="-extract i386"
diff --git a/configure.ac b/configure.ac
index 0182ecc48e097..e02cc2c65622f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -217,9 +217,15 @@ then
fi
AC_SUBST(LIPO_32BIT_FLAGS)
+AC_SUBST(LIPO_INTEL64_FLAGS)
AC_MSG_CHECKING(for --with-universal-archs)
AC_ARG_WITH(universal-archs,
- AS_HELP_STRING([--with-universal-archs=ARCH], [select architectures for universal build ("32-bit", "64-bit", "3-way", "intel", "intel-32", "intel-64", "universal2", or "all")]),
+ AS_HELP_STRING([--with-universal-archs=ARCH],
+ [specify the kind of macOS universal binary that should be created.
+ This option is only valid when --enable-universalsdk is set; options are:
+ ("universal2", "intel-64", "intel-32", "intel", "32-bit",
+ "64-bit", "3-way", or "all")
+ see Mac/README.rst]),
[
UNIVERSAL_ARCHS="$withval"
],
@@ -1832,6 +1838,7 @@ yes)
AC_MSG_RESULT($CC)
fi
+ LIPO_INTEL64_FLAGS=""
if test "${enable_universalsdk}"
then
case "$UNIVERSAL_ARCHS" in
@@ -1853,8 +1860,9 @@ yes)
universal2)
UNIVERSAL_ARCH_FLAGS="-arch arm64 -arch x86_64"
LIPO_32BIT_FLAGS=""
+ LIPO_INTEL64_FLAGS="-extract x86_64"
ARCH_RUN_32BIT="true"
- ;;
+ ;;
intel)
UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64"
LIPO_32BIT_FLAGS="-extract i386"
More information about the Python-checkins
mailing list