@@ -31,8 +31,18 @@ if [ "$1" != "." ]; then
31
31
exit 1
32
32
fi
33
33
34
+
35
+ if [ " $SAGE_PYTHON3 " = yes ]; then
36
+ PYTHON=python3
37
+ PIP=pip3
38
+ else
39
+ PYTHON=python2
40
+ PIP=pip2
41
+ fi
42
+
43
+
34
44
# Find out the name of the package that we are installing
35
- name=" $( python setup.py --name) "
45
+ name=" $( $PYTHON setup.py --name) "
36
46
37
47
if [ $? -ne 0 ]; then
38
48
echo >&2 " Error: could not determine package name"
@@ -46,29 +56,36 @@ if [ $(echo "$name" | wc -l) -gt 1 ]; then
46
56
echo >&2 " line as the package name: $name "
47
57
fi
48
58
49
- # We should avoid running pip while uninstalling a package because that
59
+
60
+ # We should avoid running pip2/3 while uninstalling a package because that
50
61
# is prone to race conditions. Therefore, we use a lockfile while
51
- # running pip. This is implemented in the Python script pip -lock.
62
+ # running pip. This is implemented in the Python script pip2/3 -lock.
52
63
53
64
# Keep uninstalling as long as it succeeds
54
65
while true ; do
55
- out=$( pip -lock uninstall --disable-pip-version-check -y " $name " 2>&1 )
66
+ out=$( $PIP -lock uninstall --disable-pip-version-check -y " $name " 2>&1 )
56
67
if [ $? -ne 0 ]; then
57
68
break
58
69
fi
59
70
echo " $out "
60
71
done
61
72
62
73
# Not ideal, but this is the easiest way to check if the package
63
- # was not installed to begin with (which pip treats as an error).
74
+ # was not installed to begin with (which pip2/3 treats as an error).
64
75
# If it wasn't, then we proceed quietly; if it was installed show the
65
76
# uninstallation output and error out.
66
77
if [[ " $out " != * " not installed" ]]; then
67
78
echo >&2 " $out "
68
79
exit 1
69
80
fi
70
81
71
- # Finally actually do the installation (the "SHARED" tells pip -lock
82
+ # Finally actually do the installation (the "SHARED" tells pip2/3 -lock
72
83
# to apply a shared lock)
73
- echo " Installing package $name using pip"
74
- exec pip-lock SHARED install $pip_install_flags .
84
+ echo " Installing package $name using $PIP "
85
+
86
+ $PIP -lock SHARED install $pip_install_flags .
87
+ if [ $? -ne 0 ]; then
88
+ echo >&2 " Error: installing with $PIP failed"
89
+ exit 3
90
+ fi
91
+
0 commit comments