1#!/bin/sh 2# 3# Install/upgrade pip. 4# 5 6PYVER="@PYVER@" 7PYMAJOR="@PYMAJOR@" 8FWK="/Library/Frameworks/Python.framework/Versions/${PYVER}" 9RELFWKBIN="../../..${FWK}/bin" 10 11umask 022 12 13"${FWK}/bin/python${PYVER}" -E -s -m ensurepip --upgrade 14 15# bpo-33290: An earlier "pip3 install --upgrade pip" may have installed 16# a "pip" in the fw bin directory. For a py3 install, remove it. 17 18rm -f "${FWK}/bin/pip" 19 20"${FWK}/bin/python${PYVER}" -E -s -Wi \ 21 "${FWK}/lib/python${PYVER}/compileall.py" -q -j0 \ 22 -f -x badsyntax \ 23 "${FWK}/lib/python${PYVER}/site-packages" 24 25"${FWK}/bin/python${PYVER}" -E -s -Wi -O \ 26 "${FWK}/lib/python${PYVER}/compileall.py" -q -j0 \ 27 -f -x badsyntax \ 28 "${FWK}/lib/python${PYVER}/site-packages" 29 30chgrp -R admin "${FWK}/lib/python${PYVER}/site-packages" "${FWK}/bin" 31chmod -R g+w "${FWK}/lib/python${PYVER}/site-packages" "${FWK}/bin" 32 33# We do not know if the user selected the Python command-line tools 34# package that installs symlinks to /usr/local/bin. So we assume 35# that the command-line tools package has already completed or was 36# not selected and we will only install /usr/local/bin symlinks for 37# pip et al if there are /usr/local/bin/python* symlinks to our 38# framework bin directory. 39 40if [ -d /usr/local/bin ] ; then 41 ( 42 install_links_if_our_fw() { 43 if [ "$(readlink -n ./$1)" = "${RELFWKBIN}/$1" ] ; then 44 shift 45 for fn ; 46 do 47 if [ -e "${RELFWKBIN}/${fn}" ] ; then 48 rm -f ./${fn} 49 ln -s "${RELFWKBIN}/${fn}" "./${fn}" 50 chgrp -h admin "./${fn}" 51 chmod -h g+w "./${fn}" 52 fi 53 done 54 fi 55 } 56 57 cd /usr/local/bin 58 59 # Create pipx.y and easy_install-x.y links if /usr/local/bin/pythonx.y 60 # is linked to this framework version 61 install_links_if_our_fw "python${PYVER}" \ 62 "pip${PYVER}" "easy_install-${PYVER}" 63 64 # Create pipx link if /usr/local/bin/pythonx is linked to this version 65 install_links_if_our_fw "python${PYMAJOR}" \ 66 "pip${PYMAJOR}" 67 68 # Create pip and easy_install link if /usr/local/bin/python 69 # is linked to this version 70 install_links_if_our_fw "python" \ 71 "pip" "easy_install" 72 ) 73fi 74exit 0 75