Ned Deily | 41ab6c3 | 2013-11-22 22:25:43 -0800 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # Install/upgrade pip. |
| 4 | # |
| 5 | |
| 6 | PYVER="@PYVER@" |
Ned Deily | ed73010 | 2014-11-14 18:55:05 -0800 | [diff] [blame] | 7 | PYMAJOR="@PYMAJOR@" |
Ned Deily | 41ab6c3 | 2013-11-22 22:25:43 -0800 | [diff] [blame] | 8 | FWK="/Library/Frameworks/Python.framework/Versions/${PYVER}" |
| 9 | RELFWKBIN="../../..${FWK}/bin" |
| 10 | |
| 11 | umask 022 |
| 12 | |
Ned Deily | 1b7f6fe | 2015-07-03 23:53:51 -0700 | [diff] [blame] | 13 | "${FWK}/bin/python${PYVER}" -E -s -m ensurepip --upgrade |
Ned Deily | 41ab6c3 | 2013-11-22 22:25:43 -0800 | [diff] [blame] | 14 | |
Ned Deily | 0dd8070 | 2018-05-02 01:30:33 -0400 | [diff] [blame] | 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 | |
| 18 | rm -f "${FWK}/bin/pip" |
| 19 | |
Ned Deily | 1b7f6fe | 2015-07-03 23:53:51 -0700 | [diff] [blame] | 20 | "${FWK}/bin/python${PYVER}" -E -s -Wi \ |
| 21 | "${FWK}/lib/python${PYVER}/compileall.py" -q -j0 \ |
Ned Deily | 41ab6c3 | 2013-11-22 22:25:43 -0800 | [diff] [blame] | 22 | -f -x badsyntax \ |
| 23 | "${FWK}/lib/python${PYVER}/site-packages" |
| 24 | |
Ned Deily | 1b7f6fe | 2015-07-03 23:53:51 -0700 | [diff] [blame] | 25 | "${FWK}/bin/python${PYVER}" -E -s -Wi -O \ |
| 26 | "${FWK}/lib/python${PYVER}/compileall.py" -q -j0 \ |
Ned Deily | 41ab6c3 | 2013-11-22 22:25:43 -0800 | [diff] [blame] | 27 | -f -x badsyntax \ |
| 28 | "${FWK}/lib/python${PYVER}/site-packages" |
| 29 | |
| 30 | chgrp -R admin "${FWK}/lib/python${PYVER}/site-packages" "${FWK}/bin" |
| 31 | chmod -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 | |
| 40 | if [ -d /usr/local/bin ] ; then |
| 41 | ( |
Ned Deily | ed73010 | 2014-11-14 18:55:05 -0800 | [diff] [blame] | 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 | |
Ned Deily | 41ab6c3 | 2013-11-22 22:25:43 -0800 | [diff] [blame] | 57 | cd /usr/local/bin |
Ned Deily | ed73010 | 2014-11-14 18:55:05 -0800 | [diff] [blame] | 58 | |
Ned Deily | 41ab6c3 | 2013-11-22 22:25:43 -0800 | [diff] [blame] | 59 | # Create pipx.y and easy_install-x.y links if /usr/local/bin/pythonx.y |
| 60 | # is linked to this framework version |
Ned Deily | ed73010 | 2014-11-14 18:55:05 -0800 | [diff] [blame] | 61 | install_links_if_our_fw "python${PYVER}" \ |
| 62 | "pip${PYVER}" "easy_install-${PYVER}" |
| 63 | |
Ned Deily | 41ab6c3 | 2013-11-22 22:25:43 -0800 | [diff] [blame] | 64 | # Create pipx link if /usr/local/bin/pythonx is linked to this version |
Ned Deily | ed73010 | 2014-11-14 18:55:05 -0800 | [diff] [blame] | 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" |
Ned Deily | 41ab6c3 | 2013-11-22 22:25:43 -0800 | [diff] [blame] | 72 | ) |
| 73 | fi |
| 74 | exit 0 |