From e51672a383b5dc6daeadeaeb9e470b0a794cebd6 Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 4 Nov 2023 16:34:56 +0100 Subject: [PATCH] fix break-system-packages, as this switch doesnt exist pre bookworm --- components/gpio_control/install.sh | 4 ++-- components/rfid-reader/PN532/setup_pn532.sh | 4 ++-- components/rfid-reader/RC522/setup_rc522.sh | 4 ++-- scripts/RegisterDevice.py.Multi | 12 ++++-------- .../installscripts/buster-install-default.sh | 19 ++++++++++++------- .../installscripts/tests/test_installation.sh | 2 +- 6 files changed, 23 insertions(+), 22 deletions(-) diff --git a/components/gpio_control/install.sh b/components/gpio_control/install.sh index 7f944033c..a8609e5fb 100755 --- a/components/gpio_control/install.sh +++ b/components/gpio_control/install.sh @@ -16,8 +16,8 @@ systemctl stop phoniebox-gpio-buttons.service systemctl disable phoniebox-gpio-buttons.service echo 'Install all required python modules' -# Allow breaking system packages (as 2.x is legacy) since Bookworm implemented PEP668 https://stackoverflow.com/a/75696359 -python3 -m pip install --upgrade --force-reinstall -r requirements.txt --break-system-packages +echo "WARNING: When using Bookworm, uncomment breaking system packages in line 20 of install.sh as Bookworm implemented PEP668 https://stackoverflow.com/a/75696359" +python3 -m pip install --upgrade --force-reinstall -r requirements.txt #--break-system-packages echo echo 'Installing GPIO_Control service' diff --git a/components/rfid-reader/PN532/setup_pn532.sh b/components/rfid-reader/PN532/setup_pn532.sh index 256745fd0..89ecff43e 100755 --- a/components/rfid-reader/PN532/setup_pn532.sh +++ b/components/rfid-reader/PN532/setup_pn532.sh @@ -33,8 +33,8 @@ else fi printf "Installing Python requirements for PN532...\n" -# Allow breaking system packages (as 2.x is legacy) since Bookworm implemented PEP668 https://stackoverflow.com/a/75696359 -sudo python3 -m pip install --upgrade --force-reinstall -q -r "${JUKEBOX_HOME_DIR}"/components/rfid-reader/PN532/requirements.txt --break-system-packages +echo "WARNING: When using Bookworm, uncomment breaking system packages in line 37 of setup_pn532.sh as Bookworm implemented PEP668 https://stackoverflow.com/a/75696359" +sudo python3 -m pip install --upgrade --force-reinstall -q -r "${JUKEBOX_HOME_DIR}"/components/rfid-reader/PN532/requirements.txt #--break-system-packages printf "Configure RFID reader in Phoniebox...\n" cp "${JUKEBOX_HOME_DIR}"/scripts/Reader.py.experimental "${JUKEBOX_HOME_DIR}"/scripts/Reader.py diff --git a/components/rfid-reader/RC522/setup_rc522.sh b/components/rfid-reader/RC522/setup_rc522.sh index f7ecf740c..6a74afd83 100644 --- a/components/rfid-reader/RC522/setup_rc522.sh +++ b/components/rfid-reader/RC522/setup_rc522.sh @@ -17,8 +17,8 @@ printf "Please make sure that the RC522 reader is wired up correctly to the GPIO question "Continue" printf "Installing Python requirements for RC522...\n" -# Allow breaking system packages (as 2.x is legacy) since Bookworm implemented PEP668 https://stackoverflow.com/a/75696359 -sudo python3 -m pip install --upgrade --force-reinstall -q -r "${JUKEBOX_HOME_DIR}"/components/rfid-reader/RC522/requirements.txt --break-system-packages +echo "WARNING: When using Bookworm, uncomment breaking system packages in line 21 of setup_rc522.sh as Bookworm implemented PEP668 https://stackoverflow.com/a/75696359" +sudo python3 -m pip install --upgrade --force-reinstall -q -r "${JUKEBOX_HOME_DIR}"/components/rfid-reader/RC522/requirements.txt #--break-system-packages printf "Activating SPI...\n" sudo raspi-config nonint do_spi 0 diff --git a/scripts/RegisterDevice.py.Multi b/scripts/RegisterDevice.py.Multi index 9a2b0f012..86dd6abf1 100644 --- a/scripts/RegisterDevice.py.Multi +++ b/scripts/RegisterDevice.py.Multi @@ -32,11 +32,9 @@ def setupPN532(): print(str(output)) return False print("Installing Python requirements for PN532...\n") - # Allow breaking system packages (as 2.x is legacy) since Bookworm implemented PEP668 https://stackoverflow.com/a/75696359 - runCmd("sudo python3 -m venv .venv") - runCmd("source .venv/bin/activate") + echo "WARNING: When using Bookworm, add --break-system-packages in line 37 of RegisterDevice.py.Multi as Bookworm implemented PEP668 https://stackoverflow.com/a/75696359" runCmd("sudo python3 -m pip install --upgrade --force-reinstall " - "-q -r {}/components/rfid-reader/PN532/requirements.txt --break-system-packages".format(JUKEBOX_HOME_DIR)) + "-q -r {}/components/rfid-reader/PN532/requirements.txt".format(JUKEBOX_HOME_DIR)) print("Done") return True @@ -47,11 +45,9 @@ def setupMFRC522(): if not answer or answer[0] != 'Y': return False print("Installing Python requirements for RC522...\n") - # Allow breaking system packages (as 2.x is legacy) since Bookworm implemented PEP668 https://stackoverflow.com/a/75696359 - runCmd("sudo python3 -m venv .venv") - runCmd("source .venv/bin/activate") + echo "WARNING: When using Bookworm, add --break-system-packages in line 50 of RegisterDevice.py.Multi as Bookworm implemented PEP668 https://stackoverflow.com/a/75696359" runCmd("sudo python3 -m pip install --upgrade --force-reinstall " - "-q -r {}/components/rfid-reader/RC522/requirements.txt --break-system-packages".format(JUKEBOX_HOME_DIR)) + "-q -r {}/components/rfid-reader/RC522/requirements.txt".format(JUKEBOX_HOME_DIR)) print("Done") return True diff --git a/scripts/installscripts/buster-install-default.sh b/scripts/installscripts/buster-install-default.sh index 8819a80d1..1cccd47ae 100644 --- a/scripts/installscripts/buster-install-default.sh +++ b/scripts/installscripts/buster-install-default.sh @@ -755,6 +755,14 @@ install_main() { local apt_get="sudo apt-get -qq --yes" local allow_downgrades="--allow-downgrades --allow-remove-essential --allow-change-held-packages" + local break_system_packages="" + if [[ ${OS_CODENAME} == "bookworm" ]]; then + # Allow breaking system packages (as 2.x is legacy) since Bookworm implemented PEP 668 https://stackoverflow.com/a/75696359 + # this switch exists only under bookworm + echo "Allowing --break-system-packages under bookworm for PEP 668" + break_system_packages="--break-system-packages" + fi + clear echo "##################################################### @@ -833,7 +841,7 @@ install_main() { fi # prepare python3 - ${apt_get} ${allow_downgrades} install python3 python3-dev python3-pip python3-setuptools python3-wheel python3-mutagen python3-gpiozero python3-spidev python3-venv + ${apt_get} ${allow_downgrades} install python3 python3-dev python3-pip python3-setuptools python3-wheel python3-mutagen python3-gpiozero python3-spidev # use python3 as default sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 1 @@ -872,14 +880,12 @@ install_main() { ${apt_get} ${allow_downgrades} install libspotify12 python3-cffi python3-ply python3-pycparser python3-spotify # Install necessary Python packages - # Allow breaking system packages (as 2.x is legacy) since Bookworm implemented PEP668 https://stackoverflow.com/a/75696359 - sudo python3 -m pip install --upgrade --force-reinstall -q -r "${jukebox_dir}"/requirements-spotify.txt --break-system-packages + sudo python3 -m pip install --upgrade --force-reinstall -q -r "${jukebox_dir}"/requirements-spotify.txt ${break-system-packages} fi # Install more required packages echo "Installing additional Python packages..." - # Allow breaking system packages (as 2.x is legacy) since Bookworm implemented PEP668 https://stackoverflow.com/a/75696359 - sudo python3 -m pip install --upgrade --force-reinstall -q -r "${jukebox_dir}"/requirements.txt --break-system-packages + sudo python3 -m pip install --upgrade --force-reinstall -q -r "${jukebox_dir}"/requirements.txt ${break-system-packages} samba_config @@ -1013,8 +1019,7 @@ install_main() { # GPIO-Control if [[ "${GPIOconfig}" == "YES" ]]; then - # Allow breaking system packages (as 2.x is legacy) since Bookworm implemented PEP668 https://stackoverflow.com/a/75696359 - sudo python3 -m pip install --upgrade --force-reinstall -q -r "${jukebox_dir}"/requirements-GPIO.txt --break-system-packages + sudo python3 -m pip install --upgrade --force-reinstall -q -r "${jukebox_dir}"/requirements-GPIO.txt ${break-system-packages} sudo systemctl enable phoniebox-gpio-control.service if [[ ! -f "${jukebox_dir}"/settings/gpio_settings.ini ]]; then cp "${jukebox_dir}"/misc/sampleconfigs/gpio_settings.ini.sample "${jukebox_dir}"/settings/gpio_settings.ini diff --git a/scripts/installscripts/tests/test_installation.sh b/scripts/installscripts/tests/test_installation.sh index 82b4d03ce..3f4a5b295 100755 --- a/scripts/installscripts/tests/test_installation.sh +++ b/scripts/installscripts/tests/test_installation.sh @@ -172,7 +172,7 @@ verify_apt_packages(){ local packages="samba samba-common-bin gcc lighttpd php${phpver}-common php${phpver}-cgi php${phpver} at mpd mpc mpg123 git ffmpeg resolvconf spi-tools python3 python3-dev python3-pip python3-setuptools python3-wheel python3-mutagen python3-gpiozero -python3-spidev python3-venv netcat-traditional alsa-utils" +python3-spidev netcat-traditional alsa-utils" local packages_raspberrypi="raspberrypi-kernel-headers" local packages_spotify="libspotify-dev mopidy mopidy-mpd mopidy-local mopidy-spotify libspotify12 python3-cffi python3-ply python3-pycparser python3-spotify"