Default --with-universal-archs to universal2 on Apple Silicon (#2122)

Don't override a user-supplied value
This commit is contained in:
native-api 2021-10-23 22:01:57 +03:00 committed by GitHub
parent a015760854
commit 8db91d5516
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 3 deletions

View file

@ -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)

View file

@ -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 <<OUT
echo "PYTHON_CONFIGURE_OPTS_ARRAY=(\${PYTHON_CONFIGURE_OPTS_ARRAY[@]})"
OUT
assert_success
assert_output <<EOS
PYTHON_CONFIGURE_OPTS_ARRAY=(--libdir=${TMP}/install/lib --enable-universalsdk=/ --with-universal-archs=intel)
PYTHON_CONFIGURE_OPTS_ARRAY=(--libdir=${TMP}/install/lib --enable-universalsdk=/)
EOS
}
@test "enable universalsdk on Apple Silicon" {
for i in {1..3}; do stub uname '-s : echo Darwin'; done
stub arch "echo arm64"
PYTHON_CONFIGURE_OPTS="--enable-universalsdk" TMPDIR="$TMP" run_inline_definition <<OUT
echo "PYTHON_CONFIGURE_OPTS_ARRAY=(\${PYTHON_CONFIGURE_OPTS_ARRAY[@]})"
OUT
assert_success
assert_output <<EOS
PYTHON_CONFIGURE_OPTS_ARRAY=(--libdir=${TMP}/install/lib --enable-universalsdk=/ --with-universal-archs=universal2)
EOS
}
@test "enable universalsdk with explicit archs argument" {
for i in {1..3}; do stub uname '-s : echo Darwin'; done
PYTHON_CONFIGURE_OPTS="--enable-universalsdk --with-universal-archs=foo" TMPDIR="$TMP" run_inline_definition <<OUT
echo "PYTHON_CONFIGURE_OPTS_ARRAY=(\${PYTHON_CONFIGURE_OPTS_ARRAY[@]})"
OUT
assert_success
assert_output <<EOS
PYTHON_CONFIGURE_OPTS_ARRAY=(--libdir=${TMP}/install/lib --enable-universalsdk=/)
EOS
}