File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -10,9 +10,17 @@ USAGE="./install.sh (--unstable)"
1010POSITIONAL_ARGS=()
1111FORCE=false
1212UNSTABLE=false
13- PYTHON=" /usr/bin/python3 "
13+ PYTHON=" python "
1414
1515
16+ venv_check () {
17+ PYTHON_BIN=` which $PYTHON `
18+ if [[ $VIRTUAL_ENV == " " ]] || [[ $PYTHON_BIN != $VIRTUAL_ENV * ]]; then
19+ printf " This script should be run in a virtual Python environment.\n"
20+ exit 1
21+ fi
22+ }
23+
1624user_check () {
1725 if [ $( id -u) -eq 0 ]; then
1826 printf " Script should not be run as root. Try './install.sh'\n"
@@ -126,6 +134,7 @@ while [[ $# -gt 0 ]]; do
126134done
127135
128136user_check
137+ venv_check
129138
130139if [ ! -f " $PYTHON " ]; then
131140 printf " Python path $PYTHON not found!\n"
@@ -179,6 +188,7 @@ printf "It's recommended you run these steps manually.\n"
179188printf "If you want to run the full script, open it in\n"
180189printf "an editor and remove 'exit 1' from below.\n"
181190exit 1
191+ source $VIRTUAL_ENV /bin/activate
182192EOF
183193
184194if $UNSTABLE ; then
Original file line number Diff line number Diff line change 33FORCE=false
44LIBRARY_NAME=` grep -m 1 name pyproject.toml | awk -F" = " ' {print substr($2,2,length($2)-2)}' `
55RESOURCES_DIR=$HOME /Pimoroni/$LIBRARY_NAME
6- PYTHON=" /usr/bin/python3"
6+ PYTHON=" python"
7+
8+
9+ venv_check () {
10+ PYTHON_BIN=` which $PYTHON `
11+ if [[ $VIRTUAL_ENV == " " ]] || [[ $PYTHON_BIN != $VIRTUAL_ENV * ]]; then
12+ printf " This script should be run in a virtual Python environment.\n"
13+ exit 1
14+ fi
15+ }
716
817user_check () {
918 if [ $( id -u) -eq 0 ]; then
@@ -49,6 +58,7 @@ warning() {
4958printf " $LIBRARY_NAME Python Library: Uninstaller\n\n"
5059
5160user_check
61+ venv_check
5262
5363printf " Uninstalling for Python 3...\n"
5464$PYTHON -m pip uninstall $LIBRARY_NAME
You can’t perform that action at this time.
0 commit comments