blob: 36d05945b6fd909789b301ed9318c42947829a90 [file] [log] [blame]
Ned Deily41ab6c32013-11-22 22:25:43 -08001#!/bin/sh
2#
3# Install/upgrade pip.
4#
5
6PYVER="@PYVER@"
Ned Deilyed730102014-11-14 18:55:05 -08007PYMAJOR="@PYMAJOR@"
Ned Deily41ab6c32013-11-22 22:25:43 -08008FWK="/Library/Frameworks/Python.framework/Versions/${PYVER}"
9RELFWKBIN="../../..${FWK}/bin"
10
11umask 022
12
Ned Deily1b7f6fe2015-07-03 23:53:51 -070013"${FWK}/bin/python${PYVER}" -E -s -m ensurepip --upgrade
Ned Deily41ab6c32013-11-22 22:25:43 -080014
Ned Deily0dd80702018-05-02 01:30:33 -040015# 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
Ned Deily1b7f6fe2015-07-03 23:53:51 -070020"${FWK}/bin/python${PYVER}" -E -s -Wi \
21 "${FWK}/lib/python${PYVER}/compileall.py" -q -j0 \
Ned Deily41ab6c32013-11-22 22:25:43 -080022 -f -x badsyntax \
23 "${FWK}/lib/python${PYVER}/site-packages"
24
Ned Deily1b7f6fe2015-07-03 23:53:51 -070025"${FWK}/bin/python${PYVER}" -E -s -Wi -O \
26 "${FWK}/lib/python${PYVER}/compileall.py" -q -j0 \
Ned Deily41ab6c32013-11-22 22:25:43 -080027 -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 (
Ned Deilyed730102014-11-14 18:55:05 -080042 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 Deily41ab6c32013-11-22 22:25:43 -080057 cd /usr/local/bin
Ned Deilyed730102014-11-14 18:55:05 -080058
Ned Deily41ab6c32013-11-22 22:25:43 -080059 # Create pipx.y and easy_install-x.y links if /usr/local/bin/pythonx.y
60 # is linked to this framework version
Ned Deilyed730102014-11-14 18:55:05 -080061 install_links_if_our_fw "python${PYVER}" \
62 "pip${PYVER}" "easy_install-${PYVER}"
63
Ned Deily41ab6c32013-11-22 22:25:43 -080064 # Create pipx link if /usr/local/bin/pythonx is linked to this version
Ned Deilyed730102014-11-14 18:55:05 -080065 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 Deily41ab6c32013-11-22 22:25:43 -080072 )
73fi
74exit 0