Skip to content

Commit

Permalink
Rework macOS sdk and filename handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
freakboy3742 committed Oct 22, 2024
1 parent e420d83 commit 915f9c7
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 37 deletions.
25 changes: 14 additions & 11 deletions osx_utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,10 @@ function macpython_sdk_list_for_version {
elif [ "$_major" -eq "3" ]; then
[ $(lex_ver $_ver) -lt $(lex_ver 3.8) ] && _return="10.6"
[ $(lex_ver $_ver) -ge $(lex_ver 3.6.5) ] && _return="$_return 10.9"
[ $(lex_ver $_ver) -ge $(lex_ver 3.9.1) ] && _return="$_return 11.0"
[ $(lex_ver $_ver) -ge $(lex_ver 3.10.0) ] && _return="11.0"
if [ "$(uname -m)" == "arm64" ]; then
[ $(lex_ver $_ver) -ge $(lex_ver 3.8.10) ] && [ "$_ver" != "3.9.0" ] && _return="$_return 11.0"
fi
[ $(lex_ver $_ver) -ge $(lex_ver 3.10.0) ] && _return="11.0"
else
echo "Error version=${_ver}, expecting 2.x or 3.x" 1>&2
exit 1
Expand Down Expand Up @@ -167,23 +169,24 @@ function pyinst_fname_for_version {
# this from $py_version using macpython_sdk_for_version
local py_version=$1
local inst_ext=$(pyinst_ext_for_version $py_version)
# Use the universal2 installer if we are on arm64
# macOS 3.8.10 and 3.9.1 introduced a second universal2 installer release.
# (3.9.0 did *not* have a universal2 installer)
# universal2 installer for python 3.8 needs macos 11.0 to run on
# and therefore x86_64 builds use the intel only installer.
# Note that intel only installer can create universal2 wheels, but
# creates intel only wheels by default. When PLAT=universal2
# we set the env variable _PYTHON_HOST_PLATFORM to change this
# default.
if [ "$(uname -m)" == "arm64" ] && [ $(lex_ver $py_version) -ge $(lex_ver 3.9.0) ] \
|| [ $(lex_ver $py_version) -ge $(lex_ver 3.10.0) ]; then
if [ "$py_version" == "3.9.1" ]; then
if [ "$py_version" == "3.9.1" ]; then
# 3.9.1 used "macos11.0" rather than "macos11" in the installer name.
echo "python-${py_version}-macos11.0.${inst_ext}"
else
echo "python-${py_version}-macos11.${inst_ext}"
fi
else
local py_osx_ver=${2:-$(macpython_sdk_for_version $py_version)}
echo "python-${py_version}-macosx${py_osx_ver}.${inst_ext}"
local py_osx_ver=${2:-$(macpython_sdk_for_version $py_version)}
if [ "$py_osx_ver" == "11.0" ]; then
echo "python-${py_version}-macos11.${inst_ext}"
else
echo "python-${py_version}-macosx${py_osx_ver}.${inst_ext}"
fi
fi
}

Expand Down
77 changes: 51 additions & 26 deletions tests/test_osx_utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,17 @@
[ "$(pyinst_fname_for_version 3.6.8)" == "python-3.6.8-macosx10.9.pkg" ] || ingest
[ "$(pyinst_fname_for_version 3.7.1)" == "python-3.7.1-macosx10.9.pkg" ] || ingest
[ "$(pyinst_fname_for_version 3.8.0)" == "python-3.8.0-macosx10.9.pkg" ] || ingest
[ "$(pyinst_fname_for_version 3.9.3)" == "python-3.9.3-macosx11.pkg" ] || ingest
[ "$(pyinst_fname_for_version 3.11.3)" == "python-3.11.3-macosx11.pkg" ] || ingest

if [ "$(uname -m)" = "arm64" ]; then
[ "$(pyinst_fname_for_version 3.8.10)" == "python-3.8.10-macos11.pkg" ] || ingest
[ "$(pyinst_fname_for_version 3.9.1)" == "python-3.9.1-macos11.0.pkg" ] || ingest
[ "$(pyinst_fname_for_version 3.9.2)" == "python-3.9.2-macos11.pkg" ] || ingest
else
[ "$(pyinst_fname_for_version 3.8.10)" == "python-3.8.10-macosx10.9.pkg" ] || ingest
[ "$(pyinst_fname_for_version 3.9.1)" == "python-3.9.1-macosx10.9.pkg" ] || ingest
[ "$(pyinst_fname_for_version 3.9.2)" == "python-3.9.2-macosx10.9.pkg" ] || ingest
fi
[ "$(pyinst_fname_for_version 3.11.3)" == "python-3.11.3-macos11.pkg" ] || ingest

[ "$(pyinst_fname_for_version 2.7.14 10.6)" == "python-2.7.14-macosx10.6.pkg" ] || ingest
[ "$(pyinst_fname_for_version 2.7.15 10.6)" == "python-2.7.15-macosx10.6.pkg" ] || ingest
Expand Down Expand Up @@ -48,36 +57,52 @@
[ "$(macpython_impl_for_version pypy-5.4)" == "pp" ] || ingest

# Test lookup of available macOS SDK build targets from python version
if [ "$(uname -m)" != "arm64" ]; then
[ "$(macpython_sdk_list_for_version 3.11.3)" == "11.0" ] || ingest
[ "$(macpython_sdk_list_for_version 3.9.3)" == "10.9 11.0" ] || ingest
[ "$(macpython_sdk_list_for_version 3.11)" == "11.0" ] || ingest
[ "$(macpython_sdk_list_for_version 3.11.3)" == "11.0" ] || ingest
if [ "$(uname -m)" = "arm64" ]; then
[ "$(macpython_sdk_list_for_version 3.9)" == "10.9 11.0" ] || ingest
[ "$(macpython_sdk_list_for_version 3.9.3)" == "10.9 11.0" ] || ingest
[ "$(macpython_sdk_list_for_version 3.9.0)" == "10.9" ] || ingest
[ "$(macpython_sdk_list_for_version 3.8)" == "10.9 11.0" ] || ingest
[ "$(macpython_sdk_list_for_version 3.8.10)" == "10.9 11.0" ] || ingest
else
[ "$(macpython_sdk_list_for_version 3.9)" == "10.9" ] || ingest
[ "$(macpython_sdk_list_for_version 3.9.3)" == "10.9" ] || ingest
[ "$(macpython_sdk_list_for_version 3.9.0)" == "10.9" ] || ingest
[ "$(macpython_sdk_list_for_version 3.8)" == "10.9" ] || ingest
[ "$(macpython_sdk_list_for_version 3.7.5)" == "10.6 10.9" ] || ingest
[ "$(macpython_sdk_list_for_version 3.7)" == "10.6 10.9" ] || ingest
[ "$(macpython_sdk_list_for_version 3.6.5)" == "10.6 10.9" ] || ingest
[ "$(macpython_sdk_list_for_version 3.6)" == "10.6 10.9" ] || ingest
[ "$(macpython_sdk_list_for_version 3.5)" == "10.6" ] || ingest
[ "$(macpython_sdk_list_for_version 2.7)" == "10.9" ] || ingest
[ "$(macpython_sdk_list_for_version 2.7.14)" == "10.6" ] || ingest
[ "$(macpython_sdk_list_for_version 2.7.15)" == "10.6 10.9" ] || ingest
[ "$(macpython_sdk_list_for_version 2.7.17)" == "10.6 10.9" ] || ingest
[ "$(macpython_sdk_list_for_version 2.7.18)" == "10.9" ] || ingest
[ "$(macpython_sdk_list_for_version 3.8.10)" == "10.9" ] || ingest
fi
[ "$(macpython_sdk_list_for_version 3.8.3)" == "10.9" ] || ingest
[ "$(macpython_sdk_list_for_version 3.7.5)" == "10.6 10.9" ] || ingest
[ "$(macpython_sdk_list_for_version 3.7)" == "10.6 10.9" ] || ingest
[ "$(macpython_sdk_list_for_version 3.6.5)" == "10.6 10.9" ] || ingest
[ "$(macpython_sdk_list_for_version 3.6)" == "10.6 10.9" ] || ingest
[ "$(macpython_sdk_list_for_version 3.5)" == "10.6" ] || ingest
[ "$(macpython_sdk_list_for_version 2.7)" == "10.9" ] || ingest
[ "$(macpython_sdk_list_for_version 2.7.14)" == "10.6" ] || ingest
[ "$(macpython_sdk_list_for_version 2.7.15)" == "10.6 10.9" ] || ingest
[ "$(macpython_sdk_list_for_version 2.7.17)" == "10.6 10.9" ] || ingest
[ "$(macpython_sdk_list_for_version 2.7.18)" == "10.9" ] || ingest

(PLAT="arm64"; [ "$(macpython_sdk_for_version 3.11)" == "11.0" ] || ingest)
(PLAT="universal2"; [ "$(macpython_sdk_for_version 3.11)" == "11.0" ] || ingest)
(PLAT="x86_64"; [ "$(macpython_sdk_for_version 3.11)" == "11.0" ] || ingest)

(PLAT="arm64"; [ "$(macpython_sdk_for_version 3.9)" == "11.0" ] || ingest)
(PLAT="universal2"; [ "$(macpython_sdk_for_version 3.9)" == "11.0" ] || ingest)
(PLAT="x86_64"; [ "$(macpython_sdk_for_version 3.9)" == "10.9" ] || ingest)
if [ "$(uname -m)" != "arm64" ]; then
[ "$(macpython_sdk_for_version 3.11)" == "11.0" ] || ingest
[ "$(macpython_sdk_for_version 3.11.3)" == "11.0" ] || ingest
if [ "$(uname -m)" = "arm64" ]; then
[ "$(macpython_sdk_for_version 3.9)" == "11.0" ] || ingest
[ "$(macpython_sdk_for_version 3.9.3)" == "11.0" ] || ingest
[ "$(macpython_sdk_for_version 3.9.0)" == "10.9" ] || ingest
[ "$(macpython_sdk_for_version 3.8)" == "11.0" ] || ingest
[ "$(macpython_sdk_for_version 3.8.10)" == "11.0" ] || ingest
else
[ "$(macpython_sdk_for_version 3.9)" == "10.9" ] || ingest
[ "$(macpython_sdk_for_version 3.9.3)" == "10.9" ] || ingest
[ "$(macpython_sdk_for_version 3.9.0)" == "10.9" ] || ingest
[ "$(macpython_sdk_for_version 3.8)" == "10.9" ] || ingest
[ "$(macpython_sdk_for_version 3.5)" == "10.6" ] || ingest
[ "$(macpython_sdk_for_version 2.7)" == "10.9" ] || ingest
[ "$(macpython_sdk_for_version 2.7.14)" == "10.6" ] || ingest
[ "$(macpython_sdk_for_version 3.8.10)" == "10.9" ] || ingest
fi
[ "$(macpython_sdk_for_version 3.8.3)" == "10.9" ] || ingest
[ "$(macpython_sdk_for_version 3.5)" == "10.6" ] || ingest
[ "$(macpython_sdk_for_version 2.7)" == "10.9" ] || ingest
[ "$(macpython_sdk_for_version 2.7.14)" == "10.6" ] || ingest

# Test pkg-config install
install_pkg_config
Expand Down

0 comments on commit 915f9c7

Please sign in to comment.