@@ -43,14 +43,15 @@ 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
5252LATEST_3p7=3.7.6
53- LATEST_3p8=3.8.0
53+ LATEST_3p8=3.8.6
54+ LATEST_3p9=3.9.0
5455
5556
5657function check_python {
@@ -107,20 +108,52 @@ function fill_pyver {
107108 echo $ver
108109 elif [ $ver == 2 ] || [ $ver == " 2.7" ]; then
109110 echo $LATEST_2p7
110- 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
111116 echo $LATEST_3p7
112117 elif [ $ver == " 3.6" ]; then
113118 echo $LATEST_3p6
114119 elif [ $ver == " 3.5" ]; then
115120 echo $LATEST_3p5
116- elif [ $ver == " 3.8" ]; then
117- echo $LATEST_3p8
118121 else
119122 echo " Can't fill version $ver " 1>&2
120123 exit 1
121124 fi
122125}
123126
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+
124157function pyinst_ext_for_version {
125158 # echo "pkg" or "dmg" depending on the passed Python version
126159 # Parameters
@@ -148,13 +181,11 @@ function pyinst_fname_for_version {
148181 # Parameters
149182 # $py_version (Python version in major.minor.extra format)
150183 # $py_osx_ver: {major.minor | not defined}
151- # if defined, the macOS version that Python is built for, e.g.
152- # "10.6" or "10.9", if not defined, uses the default
153- # MACPYTHON_DEFAULT_OSX
154- # Note: this is the version the Python is built for, and hence
155- # 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
156187 local py_version=$1
157- local py_osx_ver=${2:- $MACPYTHON_DEFAULT_OSX }
188+ local py_osx_ver=${2:- $(macpython_sdk_for_version $py_version ) }
158189 local inst_ext=$( pyinst_ext_for_version $py_version )
159190 echo " python-${py_version} -macosx${py_osx_ver} .${inst_ext} "
160191}
@@ -229,7 +260,7 @@ function macpython_impl_for_version {
229260 # "pypy-5.4" for PyPy
230261 local version=$1
231262 check_var $1
232- if [[ " $version " =~ pypy-([0-9 \. ]+) ]]; then
263+ if [[ " $version " =~ ^ pypy ]]; then
233264 echo pp
234265 elif [[ " $version " =~ ([0-9\. ]+) ]]; then
235266 echo cp
@@ -257,17 +288,17 @@ function install_macpython {
257288 # Install Python and set $PYTHON_EXE to the installed executable
258289 # Parameters:
259290 # $version : [implementation-]major[.minor[.patch]]
260- # 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 "
261292 # $py_osx_ver: {major.minor | not defined}
262293 # if defined, the macOS version that CPython is built for, e.g.
263294 # "10.6" or "10.9". Ignored for PyPy
264295 local version=$1
265296 local py_osx_ver=$2
266297 local impl=$( macpython_impl_for_version $version )
267- local stripped_ver=$( strip_macpython_ver_prefix $version )
268298 if [[ " $impl " == " pp" ]]; then
269- install_mac_pypy $stripped_ver
299+ install_pypy $version
270300 elif [[ " $impl " == " cp" ]]; then
301+ local stripped_ver=$( strip_macpython_ver_prefix $version )
271302 install_mac_cpython $stripped_ver $py_osx_ver
272303 else
273304 echo " Unexpected Python impl: ${impl} "
@@ -304,43 +335,9 @@ function install_mac_cpython {
304335 if [ -e " $inst_cmd " ]; then
305336 sh " $inst_cmd "
306337 fi
307- }
308-
309- function install_mac_pypy {
310- # Installs pypy.org PyPy
311- # Parameter $version
312- # Version given in major or major.minor or major.minor.micro e.g
313- # "3" or "3.7" or "3.7.1".
314- # sets $PYTHON_EXE variable to python executable
315- local py_version=$( fill_pypy_ver $1 )
316- local py_build=$( get_pypy_build_prefix $py_version ) $py_version -osx64
317- local py_zip=$py_build .tar.bz2
318- local zip_path=$DOWNLOADS_SDIR /$py_zip
319- mkdir -p $DOWNLOADS_SDIR
320- wget -nv $PYPY_URL /${py_zip} -P $DOWNLOADS_SDIR
321- untar $zip_path
322- PYTHON_EXE=$( realpath $py_build /bin/pypy)
323- }
324-
325- function install_pip {
326- # Generic install pip
327- # Gets needed version from version implied by $PYTHON_EXE
328- # Installs pip into python given by $PYTHON_EXE
329- # Assumes pip will be installed into same directory as $PYTHON_EXE
330- check_python
331- mkdir -p $DOWNLOADS_SDIR
332- local py_mm=` get_py_mm`
333- local get_pip_path=$DOWNLOADS_SDIR /get-pip.py
334- curl $GET_PIP_URL > $get_pip_path
335- # Travis VMS now install pip for system python by default - force install
336- # even if installed already.
337- sudo $PYTHON_EXE $get_pip_path --ignore-installed $pip_args
338- PIP_CMD=" sudo $( dirname $PYTHON_EXE ) /pip$py_mm "
339- # Append pip_args if present (avoiding trailing space cf using variable
340- # above).
341- if [ -n " $pip_args " ]; then
342- PIP_CMD=" $PIP_CMD $pip_args "
343- fi
338+ PIP_CMD=" $MACPYTHON_PY_PREFIX /$py_mm /bin/python$py_mm -m pip"
339+ $PIP_CMD install --upgrade pip
340+ export PIP_CMD
344341}
345342
346343function install_virtualenv {
@@ -375,14 +372,12 @@ function make_workon_venv {
375372# Remove previous versions
376373sudo rm -rf ${MACPYTHON_FRAMEWORK}
377374
378- for pyversion in $LATEST_3p5 $ LATEST_3p6 $LATEST_3p7 ; do
375+ for pyversion in $LATEST_3p6 $LATEST_3p7 ; do
379376 install_macpython $pyversion 10.6
380- install_pip
381377 install_virtualenv
382378done
383379
384- for pyversion in $LATEST_3p8 ; do
380+ for pyversion in $LATEST_3p8 $LATEST_3p9 ; do
385381 install_macpython $pyversion 10.9
386- install_pip
387382 install_virtualenv
388383done
0 commit comments