@@ -43,13 +43,13 @@ GET_PIP_URL=https://bootstrap.pypa.io/get-pip.py
4343DOWNLOADS_SDIR=downloads
4444WORKING_SDIR=working
4545
46- # As of 24 Oct 2019 - latest Python of each version with binary download
46+ # As of 24 September 2020 - latest Python of each version with binary download
4747# available.
4848# See: https://www.python.org/downloads/mac-osx/
49- LATEST_2p7=2.7.17
49+ LATEST_2p7=2.7.18
5050LATEST_3p5=3.5.4
5151LATEST_3p6=3.6.8
52- LATEST_3p7=3.7.6
52+ LATEST_3p7=3.7.9
5353LATEST_3p8=3.8.6
5454LATEST_3p9=3.9.0
5555
@@ -108,22 +108,52 @@ function fill_pyver {
108108 echo $ver
109109 elif [ $ver == 2 ] || [ $ver == " 2.7" ]; then
110110 echo $LATEST_2p7
111- elif [ $ver == 3 ] || [ $ver == " 3.7" ]; then
111+ elif [ $ver == 3 ] || [ $ver == " 3.9" ]; then
112+ echo $LATEST_3p9
113+ elif [ $ver == " 3.8" ]; then
114+ echo $LATEST_3p8
115+ elif [ $ver == " 3.7" ]; then
112116 echo $LATEST_3p7
113117 elif [ $ver == " 3.6" ]; then
114118 echo $LATEST_3p6
115119 elif [ $ver == " 3.5" ]; then
116120 echo $LATEST_3p5
117- elif [ $ver == " 3.8" ]; then
118- echo $LATEST_3p8
119- elif [ $ver == " 3.9" ]; then
120- echo $LATEST_3p9
121121 else
122122 echo " Can't fill version $ver " 1>&2
123123 exit 1
124124 fi
125125}
126126
127+ function macpython_sdk_list_for_version {
128+ # return a list of SDK targets supported for a given CPython version
129+ # Parameters
130+ # $py_version (python version in major.minor.extra format)
131+ # eg
132+ # macpython_sdks_for_version 2.7.15
133+ # >> 10.6 10.9
134+ local _ver=$( fill_pyver $1 )
135+ local _major=${_ver%% .* }
136+ local _return
137+
138+ if [ " $_major " -eq " 2" ]; then
139+ [ $( lex_ver $_ver ) -lt $( lex_ver 2.7.18) ] && _return=" 10.6"
140+ [ $( lex_ver $_ver ) -ge $( lex_ver 2.7.15) ] && _return=" $_return 10.9"
141+ elif [ " $_major " -eq " 3" ]; then
142+ [ $( lex_ver $_ver ) -lt $( lex_ver 3.8) ] && _return=" 10.6"
143+ [ $( lex_ver $_ver ) -ge $( lex_ver 3.6.5) ] && _return=" $_return 10.9"
144+ else
145+ echo " Error version=${_ver} , expecting 2.x or 3.x" 1>&2
146+ exit 1
147+ fi
148+ echo $_return
149+ }
150+
151+ function macpython_sdk_for_version {
152+ # assumes the output of macpython_sdk_list_for_version is a list
153+ # of SDK versions XX.Y in sorted order, eg "10.6 10.9" or "10.9"
154+ echo $( macpython_sdk_list_for_version $1 ) | awk -F' ' ' {print $NF}'
155+ }
156+
127157function pyinst_ext_for_version {
128158 # echo "pkg" or "dmg" depending on the passed Python version
129159 # Parameters
@@ -151,13 +181,11 @@ function pyinst_fname_for_version {
151181 # Parameters
152182 # $py_version (Python version in major.minor.extra format)
153183 # $py_osx_ver: {major.minor | not defined}
154- # if defined, the macOS version that Python is built for, e.g.
155- # "10.6" or "10.9", if not defined, uses the default
156- # MACPYTHON_DEFAULT_OSX
157- # Note: this is the version the Python is built for, and hence
158- # the min version supported, NOT the version of the current system
184+ # if defined, the minimum macOS SDK version that Python is
185+ # built for, eg: "10.6" or "10.9", if not defined, infers
186+ # this from $py_version using macpython_sdk_for_version
159187 local py_version=$1
160- local py_osx_ver=${2:- $MACPYTHON_DEFAULT_OSX }
188+ local py_osx_ver=${2:- $(macpython_sdk_for_version $py_version ) }
161189 local inst_ext=$( pyinst_ext_for_version $py_version )
162190 echo " python-${py_version} -macosx${py_osx_ver} .${inst_ext} "
163191}
@@ -232,7 +260,7 @@ function macpython_impl_for_version {
232260 # "pypy-5.4" for PyPy
233261 local version=$1
234262 check_var $1
235- if [[ " $version " =~ pypy-([0-9 \. ]+) ]]; then
263+ if [[ " $version " =~ ^ pypy ]]; then
236264 echo pp
237265 elif [[ " $version " =~ ([0-9\. ]+) ]]; then
238266 echo cp
@@ -260,17 +288,17 @@ function install_macpython {
260288 # Install Python and set $PYTHON_EXE to the installed executable
261289 # Parameters:
262290 # $version : [implementation-]major[.minor[.patch]]
263- # The Python implementation to install, e.g. "3.6" or "pypy-5.4"
291+ # The Python implementation to install, e.g. "3.6", "pypy-5.4" or "pypy3.6-7.2 "
264292 # $py_osx_ver: {major.minor | not defined}
265293 # if defined, the macOS version that CPython is built for, e.g.
266294 # "10.6" or "10.9". Ignored for PyPy
267295 local version=$1
268296 local py_osx_ver=$2
269297 local impl=$( macpython_impl_for_version $version )
270- local stripped_ver=$( strip_macpython_ver_prefix $version )
271298 if [[ " $impl " == " pp" ]]; then
272- install_mac_pypy $stripped_ver
299+ install_pypy $version
273300 elif [[ " $impl " == " cp" ]]; then
301+ local stripped_ver=$( strip_macpython_ver_prefix $version )
274302 install_mac_cpython $stripped_ver $py_osx_ver
275303 else
276304 echo " Unexpected Python impl: ${impl} "
@@ -291,10 +319,11 @@ function install_mac_cpython {
291319 # sets $PYTHON_EXE variable to Python executable
292320 local py_version=$( fill_pyver $1 )
293321 local py_osx_ver=$2
322+ local py_stripped=$( strip_ver_suffix $py_version )
294323 local py_inst=$( pyinst_fname_for_version $py_version $py_osx_ver )
295324 local inst_path=$DOWNLOADS_SDIR /$py_inst
296325 mkdir -p $DOWNLOADS_SDIR
297- curl $MACPYTHON_URL /$py_version /${py_inst} > $inst_path
326+ curl $MACPYTHON_URL /$py_stripped /${py_inst} > $inst_path
298327 if [ " ${py_inst: -3} " == " dmg" ]; then
299328 hdiutil attach $inst_path -mountpoint /Volumes/Python
300329 inst_path=/Volumes/Python/Python.mpkg
@@ -309,43 +338,6 @@ function install_mac_cpython {
309338 fi
310339}
311340
312- function install_mac_pypy {
313- # Installs pypy.org PyPy
314- # Parameter $version
315- # Version given in major or major.minor or major.minor.micro e.g
316- # "3" or "3.7" or "3.7.1".
317- # sets $PYTHON_EXE variable to python executable
318- local py_version=$( fill_pypy_ver $1 )
319- local py_build=$( get_pypy_build_prefix $py_version ) $py_version -osx64
320- local py_zip=$py_build .tar.bz2
321- local zip_path=$DOWNLOADS_SDIR /$py_zip
322- mkdir -p $DOWNLOADS_SDIR
323- wget -nv $PYPY_URL /${py_zip} -P $DOWNLOADS_SDIR
324- untar $zip_path
325- PYTHON_EXE=$( realpath $py_build /bin/pypy)
326- }
327-
328- function install_pip {
329- # Generic install pip
330- # Gets needed version from version implied by $PYTHON_EXE
331- # Installs pip into python given by $PYTHON_EXE
332- # Assumes pip will be installed into same directory as $PYTHON_EXE
333- check_python
334- mkdir -p $DOWNLOADS_SDIR
335- local py_mm=` get_py_mm`
336- local get_pip_path=$DOWNLOADS_SDIR /get-pip.py
337- curl $GET_PIP_URL > $get_pip_path
338- # Travis VMS now install pip for system python by default - force install
339- # even if installed already.
340- sudo $PYTHON_EXE $get_pip_path --ignore-installed $pip_args
341- PIP_CMD=" sudo $( dirname $PYTHON_EXE ) /pip$py_mm "
342- # Append pip_args if present (avoiding trailing space cf using variable
343- # above).
344- if [ -n " $pip_args " ]; then
345- PIP_CMD=" $PIP_CMD $pip_args "
346- fi
347- }
348-
349341function install_virtualenv {
350342 # Generic install of virtualenv
351343 # Installs virtualenv into python given by $PYTHON_EXE
0 commit comments