• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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}" -m ensurepip --upgrade
14
15"${FWK}/bin/python${PYVER}" -Wi \
16    "${FWK}/lib/python${PYVER}/compileall.py" \
17    -f -x badsyntax \
18    "${FWK}/lib/python${PYVER}/site-packages"
19
20"${FWK}/bin/python${PYVER}" -Wi -O \
21    "${FWK}/lib/python${PYVER}/compileall.py" \
22    -f -x badsyntax \
23    "${FWK}/lib/python${PYVER}/site-packages"
24
25chgrp -R admin "${FWK}/lib/python${PYVER}/site-packages" "${FWK}/bin"
26chmod -R g+w "${FWK}/lib/python${PYVER}/site-packages" "${FWK}/bin"
27
28# We do not know if the user selected the Python command-line tools
29# package that installs symlinks to /usr/local/bin.  So we assume
30# that the command-line tools package has already completed or was
31# not selected and we will only install /usr/local/bin symlinks for
32# pip et al if there are /usr/local/bin/python* symlinks to our
33# framework bin directory.
34
35if [ -d /usr/local/bin ] ; then
36    (
37        install_links_if_our_fw() {
38            if [ "$(readlink -n ./$1)" = "${RELFWKBIN}/$1" ] ; then
39                shift
40                for fn ;
41                do
42                    if [ -e "${RELFWKBIN}/${fn}" ] ; then
43                        rm -f ./${fn}
44                        ln -s "${RELFWKBIN}/${fn}" "./${fn}"
45                        chgrp -h admin "./${fn}"
46                        chmod -h g+w "./${fn}"
47                    fi
48                done
49            fi
50        }
51
52        cd /usr/local/bin
53
54        # Create pipx.y and easy_install-x.y links if /usr/local/bin/pythonx.y
55        #   is linked to this framework version
56        install_links_if_our_fw "python${PYVER}" \
57                                    "pip${PYVER}" "easy_install-${PYVER}"
58
59        # Create pipx link if /usr/local/bin/pythonx is linked to this version
60        install_links_if_our_fw "python${PYMAJOR}" \
61                                    "pip${PYMAJOR}"
62
63        # Create pip and easy_install link if /usr/local/bin/python
64        #   is linked to this version
65        install_links_if_our_fw "python" \
66                                    "pip" "easy_install"
67    )
68fi
69exit 0
70