forked from MacPython/terryfy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_python_installs.sh
122 lines (115 loc) · 3.24 KB
/
test_python_installs.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# Some debug echoes
echo "Python on path: `which python`"
echo "Python cmd: $PYTHON_EXE"
$PYTHON_EXE --version
if [ $? -ne 0 ] ; then RET=1; fi
echo "pip on path: `which pip`"
echo "pip cmd: $PIP_CMD"
$PIP_CMD --version
if [ $? -ne 0 ] ; then RET=1; fi
echo "virtualenv on path: `which virtualenv`"
echo "virtualenv cmd: $VIRTUALENV_CMD"
# Check that a pip install puts scripts on path
$PIP_CMD install delocate
delocate-listdeps --version
if [ $? -ne 0 ] ; then RET=1; fi
# Run the site-packages command
echo "Site packages: `get_py_site_packages`"
if [ $? -ne 0 ] ; then RET=1; fi
# Python version information
python_version=`$PYTHON_EXE -c \
'import sys; print("{}.{}.{}".format(*sys.version_info[:3]))'`
python_mm=${python_version:0:3}
python_m=${python_version:0:1}
case $INSTALL_TYPE in
macpython)
if [ "$python_version" != "$VERSION" ]; then
echo "Wrong macpython python version"
RET=1
fi
;;
system|macports)
if [ "$python_mm" != "$VERSION" ]; then
echo "Wrong macports python version"
RET=1
fi
;;
homebrew)
if [ "$python_m" != "$VERSION" ]; then
echo "Wrong homebrew python version"
RET=1
fi
;;
esac
if [ -n "$VENV" ]; then
if [ "$PYTHON_EXE" != "$PWD/venv/bin/python" ]; then
echo "Wrong virtualenv python"
RET = 1
fi
if [ "$PIP_CMD" != "$PWD/venv/bin/pip" ]; then
echo "Wrong virtualenv pip"
RET=1
fi
# Check site-packages toggling doesn't error (at least)
toggle_py_sys_site_packages
toggle_py_sys_site_packages
if [ $? -ne 0 ] ; then RET=1; fi
else # not virtualenv
case $INSTALL_TYPE in
system)
if [ "$PYTHON_EXE" != "/usr/bin/python" ]; then
echo "Wrong system python cmd"
RET=1
fi
if [ "$PIP_CMD" != "sudo /usr/local/bin/pip" ]; then
echo "Wrong system pip"
RET=1
fi
;;
macpython)
macpie_bin="$MACPYTHON_PY_PREFIX/$python_mm/bin"
if [ "$PYTHON_EXE" != "$macpie_bin/python$python_mm" ]; then
echo "Wrong macpython python cmd"
RET=1
fi
if [ "$PIP_CMD" != "sudo $macpie_bin/pip$python_mm" ]; then
echo "Wrong macpython pip"
RET=1
fi
;;
macports)
macports_pie_bin="$MACPORTS_PY_PREFIX/$python_mm/bin"
if [ "$PYTHON_EXE" != "$macports_pie_bin/python$python_mm" ]; then
echo "Wrong macports python cmd"
RET=1
fi
if [ "$PIP_CMD" != "sudo /opt/local/bin/pip-$python_mm" ]; then
echo "Wrong macports pip"
RET=1
fi
;;
homebrew)
if [ "$PYTHON_EXE" != "/usr/local/bin/python$python_m" ]; then
echo "Wrong homebrew python cmd"
RET=1
fi
if [ "$PIP_CMD" != "/usr/local/bin/pip$python_m" ]; then
echo "Wrong homebrew pip"
RET=1
fi
;;
esac
fi
# Check sudo
if [ -n "$VENV" ] || [ "$INSTALL_TYPE" == "homebrew" ]; then
# Sudo should be empty
if [ -n "`get_pip_sudo`" ]; then
echo "pip sudo should be empty"
RET=1
fi
else # sudo should be set
if [ "`get_pip_sudo`" != "sudo" ]; then
echo "pip sudo not set"
RET=1
fi
fi