Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raspberry Pi OS Bookworm + Pep 668 #13

Merged
merged 22 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
8ebf5b3
Enforce use of a virtual environment.
Gadgetoid Oct 16, 2023
fc12d7d
Add option to manage venv if it's not detected.
Gadgetoid Oct 16, 2023
c8b2011
QA: Drop --format argument from ruff.
Gadgetoid Oct 17, 2023
d9710f7
Drop an auto venv script into ~/Pimoroni, update venv prompt
Gadgetoid Oct 19, 2023
896b3b5
Switch venv location to virtualenvwrapper default.
Gadgetoid Oct 23, 2023
bd3bf8b
Tweaks to install and tool.pimoroni
Gadgetoid Oct 23, 2023
6e4dabc
CI: Set term in check.sh for GitHub Actions.
Gadgetoid Nov 6, 2023
b74d0c6
Better handling of /boot/config.txt and /boot/firmware/config.txt
Gadgetoid Nov 15, 2023
66f69e3
Fix VENV_DIR path.
Gadgetoid Nov 21, 2023
a9db28c
Fix auto_venv.sh creation.
Gadgetoid Nov 22, 2023
5a2228e
install.sh: normalise whitespace.
Gadgetoid Nov 22, 2023
fceeafb
install.sh: rework for better error reporting and fix some bugs.
Gadgetoid Nov 23, 2023
e8f9443
README.md: Correct coveralls badge branch.
Gadgetoid Dec 5, 2023
39d73f7
CI: Update GitHub Actions versions.
damacus Jan 8, 2024
5e294af
QA: Add shellcheck and fix/ignore all issues.
Gadgetoid Jan 9, 2024
f0e3f93
install.sh: slightly better feedback for setup commands.
Gadgetoid Jan 10, 2024
d6a2c6d
install.sh: fix quoting bug in do_config_backup.
Gadgetoid Jan 10, 2024
3c9d88a
install.sh: don't output printf commands.
Gadgetoid Jan 10, 2024
367cd22
install.sh: drop symlink warning for /boot/config.txt.
Gadgetoid Mar 11, 2024
31b961c
install.sh: drop quotes around apt packages.
Gadgetoid Apr 17, 2024
6bb337c
Makefile: fail make tag if dev tools not installed.
Gadgetoid Apr 29, 2024
c2d4193
tox.ini: update ruff invocation to avoid deprecation warning.
Gadgetoid May 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ DATESTAMP=`date "+%Y-%m-%d-%H-%M-%S"`
CONFIG_BACKUP=false
APT_HAS_UPDATED=false
RESOURCES_TOP_DIR=$HOME/Pimoroni
PY_VENV_DIR=$RESOURCES_TOP_DIR/venv
WD=`pwd`
USAGE="./install.sh (--unstable)"
POSITIONAL_ARGS=()
FORCE=false
UNSTABLE=false
PYTHON="/usr/bin/python3"
PYTHON="python"


user_check() {
Expand Down Expand Up @@ -54,6 +55,28 @@ warning() {
echo -e "$(tput setaf 1)$1$(tput sgr0)"
}

venv_check() {
PYTHON_BIN=`which $PYTHON`
if [[ $VIRTUAL_ENV == "" ]] || [[ $PYTHON_BIN != $VIRTUAL_ENV* ]]; then
printf "This script should be run in a virtual Python environment.\n"
if confirm "Would you like us to create one for you?"; then
if [ ! -f $PY_VENV_DIR/bin/activate ]; then
inform "Creating virtual Python environment in $PY_VENV_DIR, please wait...\n"
mkdir -p $PY_VENV_DIR
/usr/bin/python3 -m venv $PY_VENV_DIR --system-site-packages

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be nice to add --prompt Pimoroni or something similar to the creation of the venv so that when the environment is activated, the user's prompt changes to (Pimoroni) pi@raspberrypi:~ $ which at least indicates that they're in a Pimoroni environment. The default prompt of (venv) pi@raspberrypi:~ $ is a little confusing as it's not clear which "venv" you have activated.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for taking the time to look at this. I'm keenly aware that foisting something like this upon users should be done at least somewhat carefully, and thus any and all feedback is really, really appreciated.

TLDR: Yes, I totally agree!

else
inform "Found existing virtual Python environment in $PY_VENV_DIR\n"
fi
inform "Activating virtual Python environment in $PY_VENV_DIR..."
inform "source $PY_VENV_DIR/bin/activate\n"
source $PY_VENV_DIR/bin/activate

else
exit 1
fi
fi
}

function do_config_backup {
if [ ! $CONFIG_BACKUP == true ]; then
CONFIG_BACKUP=true
Expand Down Expand Up @@ -126,8 +149,9 @@ while [[ $# -gt 0 ]]; do
done

user_check
venv_check

if [ ! -f "$PYTHON" ]; then
if [ ! -f `which $PYTHON` ]; then
printf "Python path $PYTHON not found!\n"
exit 1
fi
Expand Down Expand Up @@ -179,6 +203,7 @@ printf "It's recommended you run these steps manually.\n"
printf "If you want to run the full script, open it in\n"
printf "an editor and remove 'exit 1' from below.\n"
exit 1
source $VIRTUAL_ENV/bin/activate
EOF

if $UNSTABLE; then
Expand Down
12 changes: 11 additions & 1 deletion uninstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,16 @@
FORCE=false
LIBRARY_NAME=`grep -m 1 name pyproject.toml | awk -F" = " '{print substr($2,2,length($2)-2)}'`
RESOURCES_DIR=$HOME/Pimoroni/$LIBRARY_NAME
PYTHON="/usr/bin/python3"
PYTHON="python"


venv_check() {
PYTHON_BIN=`which $PYTHON`
if [[ $VIRTUAL_ENV == "" ]] || [[ $PYTHON_BIN != $VIRTUAL_ENV* ]]; then
printf "This script should be run in a virtual Python environment.\n"
exit 1
fi
}

user_check() {
if [ $(id -u) -eq 0 ]; then
Expand Down Expand Up @@ -49,6 +58,7 @@ warning() {
printf "$LIBRARY_NAME Python Library: Uninstaller\n\n"

user_check
venv_check

printf "Uninstalling for Python 3...\n"
$PYTHON -m pip uninstall $LIBRARY_NAME
Expand Down
Loading