diff --git a/plugins/python-build/bin/python-build b/plugins/python-build/bin/python-build index fdd7aec2..e7f79a45 100755 --- a/plugins/python-build/bin/python-build +++ b/plugins/python-build/bin/python-build @@ -2137,13 +2137,21 @@ if [[ "$CONFIGURE_OPTS $PYTHON_CONFIGURE_OPTS" == *"--enable-framework"* ]]; the package_option python configure --enable-framework="${PREFIX_PATH}/Library/Frameworks" fi -# Build against universal SDK (#219, #220) +# Build against universal SDK if [[ "$CONFIGURE_OPTS $PYTHON_CONFIGURE_OPTS" == *"--enable-universalsdk"* ]]; then if ! is_mac; then echo "python-build: universal installation is not supported." >&2 exit 1 fi - package_option python configure --enable-universalsdk=/ --with-universal-archs=intel + package_option python configure --enable-universalsdk=/ + if [[ "$CONFIGURE_OPTS $PYTHON_CONFIGURE_OPTS" != *"--enable-universal-archs"* ]]; then + # in CPython's configure.ac, --with-universal-archs defaults to 'intel' which means i386 + x86_64 + # since 2.7.5 and 3.3.0 -- i.e. in all non-EOL versions + # Apple Silicon cannot build these, in it, it rather makes sense to default to Universal2 binaries + if [[ $(arch) == "arm64" ]]; then + package_option python configure --with-universal-archs=universal2 + fi + fi fi # Compile with `--enable-unicode=ucs4` by default (#257) diff --git a/plugins/python-build/test/pyenv_ext.bats b/plugins/python-build/test/pyenv_ext.bats index 9afb0ac7..74a590fb 100644 --- a/plugins/python-build/test/pyenv_ext.bats +++ b/plugins/python-build/test/pyenv_ext.bats @@ -273,13 +273,41 @@ EOS @test "enable universalsdk" { for i in {1..3}; do stub uname '-s : echo Darwin'; done + stub arch "echo x86_64" PYTHON_CONFIGURE_OPTS="--enable-universalsdk" TMPDIR="$TMP" run_inline_definition <