@@ -43,15 +43,15 @@ GET_PIP_URL=https://bootstrap.pypa.io/get-pip.py
4343DOWNLOADS_SDIR=downloads
4444WORKING_SDIR=working
4545
46- # As of 26 January 2021 - latest Python of each version with binary download
46+ # As of 5 April 2021 - latest Python of each version with binary download
4747# available.
4848# See: https://www.python.org/downloads/mac-osx/
4949LATEST_2p7=2.7.18
5050LATEST_3p5=3.5.4
5151LATEST_3p6=3.6.8
5252LATEST_3p7=3.7.9
53- LATEST_3p8=3.8.7
54- LATEST_3p9=3.9.1
53+ LATEST_3p8=3.8.9
54+ LATEST_3p9=3.9.4
5555
5656
5757function check_python {
@@ -135,7 +135,9 @@ function macpython_sdk_list_for_version {
135135 local _major=${_ver%% .* }
136136 local _return
137137
138- if [ " $_major " -eq " 2" ]; then
138+ if [ " ${PLAT} " = " arm64" ]; then
139+ _return=" 11.0"
140+ elif [ " $_major " -eq " 2" ]; then
139141 [ $( lex_ver $_ver ) -lt $( lex_ver 2.7.18) ] && _return=" 10.6"
140142 [ $( lex_ver $_ver ) -ge $( lex_ver 2.7.15) ] && _return=" $_return 10.9"
141143 elif [ " $_major " -eq " 3" ]; then
@@ -187,7 +189,15 @@ function pyinst_fname_for_version {
187189 local py_version=$1
188190 local py_osx_ver=${2:- $(macpython_sdk_for_version $py_version )}
189191 local inst_ext=$( pyinst_ext_for_version $py_version )
190- echo " python-${py_version} -macosx${py_osx_ver} .${inst_ext} "
192+ if [ " ${PLAT:- } " == " arm64" ] || [ " ${PLAT:- } " == " universal2" ]; then
193+ if [ " $py_version " == " 3.9.1" ]; then
194+ echo " python-${py_version} -macos11.0.${inst_ext} "
195+ else
196+ echo " python-${py_version} -macos11.${inst_ext} "
197+ fi
198+ else
199+ echo " python-${py_version} -macosx${py_osx_ver} .${inst_ext} "
200+ fi
191201}
192202
193203function get_macpython_arch {
@@ -200,7 +210,7 @@ function get_macpython_arch {
200210 # Note: MUST only be called after the version of Python used to build the
201211 # target wheel has been installed and is on the path
202212 local distutils_plat=${1:- $(get_distutils_platform)}
203- if [[ $distutils_plat =~ macosx-(10 \. [0-9]+)-(.* ) ]]; then
213+ if [[ $distutils_plat =~ macosx-(1[0-9] \. [0-9]+)-(.* ) ]]; then
204214 echo ${BASH_REMATCH[2]}
205215 else
206216 echo " Error parsing macOS distutils platform '$distutils_plat '"
@@ -218,7 +228,7 @@ function get_macpython_osx_ver {
218228 # Note: MUST only be called after the version of Python used to build the
219229 # target wheel has been installed and is on the path
220230 local distutils_plat=${1:- $(get_distutils_platform)}
221- if [[ $distutils_plat =~ macosx-(10 \. [0-9]+)-(.* ) ]]; then
231+ if [[ $distutils_plat =~ macosx-(1[0-9] \. [0-9]+)-(.* ) ]]; then
222232 echo ${BASH_REMATCH[1]}
223233 else
224234 echo " Error parsing macOS distutils platform '$distutils_plat '"
@@ -319,10 +329,19 @@ function install_mac_cpython {
319329 # sets $PYTHON_EXE variable to Python executable
320330 local py_version=$( fill_pyver $1 )
321331 local py_osx_ver=$2
332+ # local py_stripped=$(strip_ver_suffix $py_version)
333+ local py_stripped=$py_version
322334 local py_inst=$( pyinst_fname_for_version $py_version $py_osx_ver )
323335 local inst_path=$DOWNLOADS_SDIR /$py_inst
336+ local retval=" "
324337 mkdir -p $DOWNLOADS_SDIR
325- curl $MACPYTHON_URL /$py_version /${py_inst} > $inst_path
338+ # exit early on curl errors, but don't let it exit the shell
339+ curl -f $MACPYTHON_URL /$py_stripped /${py_inst} > $inst_path || retval=$?
340+ if [ ${retval:- 0} -ne 0 ]; then
341+ echo " Python download failed! Check ${py_inst} exists on the server."
342+ exit $retval
343+ fi
344+
326345 if [ " ${py_inst: -3} " == " dmg" ]; then
327346 hdiutil attach $inst_path -mountpoint /Volumes/Python
328347 inst_path=/Volumes/Python/Python.mpkg
@@ -372,12 +391,22 @@ function make_workon_venv {
372391# Remove previous versions
373392sudo rm -rf ${MACPYTHON_FRAMEWORK}
374393
375- for pyversion in $LATEST_3p6 ; do
376- install_macpython $pyversion 10.6
377- install_virtualenv
378- done
379-
380- for pyversion in $LATEST_3p7 $LATEST_3p8 $LATEST_3p9 ; do
381- install_macpython $pyversion 10.9
382- install_virtualenv
383- done
394+ if test " $( arch) " == " arm64" ; then
395+ echo " we are arm"
396+ PLAT=arm64
397+ for pyversion in $LATEST_3p9 ; do
398+ install_macpython $pyversion 11
399+ install_virtualenv
400+ done
401+ else
402+ # intel
403+ for pyversion in $LATEST_3p6 ; do
404+ install_macpython $pyversion 10.6
405+ install_virtualenv
406+ done
407+
408+ for pyversion in $LATEST_3p7 $LATEST_3p8 $LATEST_3p9 ; do
409+ install_macpython $pyversion 10.9
410+ install_virtualenv
411+ done
412+ fi
0 commit comments