Skip to content

Commit

Permalink
fix break-system-packages, as this switch doesnt exist pre bookworm
Browse files Browse the repository at this point in the history
  • Loading branch information
s-martin committed Nov 4, 2023
1 parent ef235d7 commit e51672a
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 22 deletions.
4 changes: 2 additions & 2 deletions components/gpio_control/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions components/rfid-reader/PN532/setup_pn532.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions components/rfid-reader/RC522/setup_rc522.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 4 additions & 8 deletions scripts/RegisterDevice.py.Multi
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
19 changes: 12 additions & 7 deletions scripts/installscripts/buster-install-default.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "#####################################################
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion scripts/installscripts/tests/test_installation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit e51672a

Please sign in to comment.