|
1 | 1 | #!/usr/bin/env bash
|
2 |
| -# This command is specifically for pip-installing from a local |
3 |
| -# source directory, as opposed to from a package index via package |
4 |
| -# name. That is, it is for pip-installing Sage spkgs from their |
5 |
| -# extracted upstream sources. |
| 2 | +# This command is specifically for pip-installing a previously |
| 3 | +# built wheel. |
6 | 4 | #
|
7 | 5 | # This ensures that any previous installations of the same package
|
8 | 6 | # are uninstalled first.
|
|
17 | 15 | # This also disables pip's version self-check.
|
18 | 16 | # --isolated : Don't read configuration files such as
|
19 | 17 | # ~/.pydistutils.cfg
|
20 |
| -# --no-build-isolation:Build the package in the usual Python environment |
21 |
| -# (containing the dependencies) instead of an |
22 |
| -# "isolated" environment |
23 |
| -pip_install_flags="--ignore-installed --verbose --no-deps --no-index --isolated --no-build-isolation" |
24 |
| - |
25 |
| -# Consume any additional pip install arguments except the last one |
26 |
| -while [ $# -gt 1 ]; do |
27 |
| - pip_install_flags="$pip_install_flags $1" |
28 |
| - shift |
29 |
| -done |
30 |
| - |
31 |
| -# Last argument must be "." and will be ignored |
32 |
| -if [ "$1" != "." ]; then |
33 |
| - echo >&2 "$0 requires . as final argument" |
34 |
| - exit 1 |
35 |
| -fi |
36 |
| - |
| 18 | +pip_install_flags="--ignore-installed --verbose --no-deps --no-index --isolated" |
37 | 19 |
|
38 | 20 | # Note: We need to take care to specify the full path to Sage's Python here
|
39 | 21 | # to emphasize that this command hould use it, and not the system Python;
|
|
48 | 30 | PIP=pip2
|
49 | 31 | fi
|
50 | 32 |
|
51 |
| - |
52 |
| -# Find out the name of the package that we are installing |
53 |
| -name="$($PYTHON setup.py --name)" |
54 |
| - |
55 |
| -if [ $? -ne 0 ]; then |
56 |
| - echo >&2 "Error: could not determine package name" |
57 |
| - exit 1 |
58 |
| -fi |
59 |
| - |
60 |
| -if [ $(echo "$name" | wc -l) -gt 1 ]; then |
61 |
| - name="$(echo "$name" | tail -1)" |
62 |
| - echo >&2 "Warning: This package has a badly-behaved setup.py which outputs" |
63 |
| - echo >&2 "more than the package name for 'setup.py --name'; using the last" |
64 |
| - echo >&2 "line as the package name: $name" |
65 |
| -fi |
66 |
| - |
67 |
| - |
68 | 33 | # We should avoid running pip2/3 while uninstalling a package because that
|
69 | 34 | # is prone to race conditions. Therefore, we use a lockfile while
|
70 | 35 | # running pip. This is implemented in the Python script sage-flock
|
71 | 36 | LOCK="$SAGE_LOCAL/var/lock/$PIP.lock"
|
72 | 37 |
|
73 |
| -# Keep uninstalling as long as it succeeds |
74 |
| -while true; do |
75 |
| - out=$(sage-flock -x $LOCK $PYTHON -m pip uninstall --disable-pip-version-check -y "$name" 2>&1) |
76 |
| - if [ $? -ne 0 ]; then |
77 |
| - # Uninstall failed |
78 |
| - echo >&2 "$out" |
79 |
| - exit 1 |
80 |
| - fi |
81 |
| - |
82 |
| - # Uninstall succeeded, which may mean that the package was not |
83 |
| - # installed to begin with. |
84 |
| - if [[ "$out" != *"not installed" ]]; then |
85 |
| - break |
86 |
| - fi |
87 |
| -done |
88 |
| - |
89 |
| - |
90 | 38 | # Finally actually do the installation (the "SHARED" tells pip2/3-lock
|
91 | 39 | # to apply a shared lock)
|
92 |
| -echo "Installing package $name using $PIP" |
93 |
| - |
94 |
| -sage-flock -s $LOCK $PYTHON -m pip install $pip_install_flags . |
| 40 | +sage-flock -s $LOCK $PYTHON -m pip install $pip_install_flags "$@" |
95 | 41 | if [ $? -ne 0 ]; then
|
96 | 42 | echo >&2 "Error: installing with $PIP failed"
|
97 | 43 | exit 3
|
|
0 commit comments