diff --git a/.github/workflows/pythonpackage_future3.yml b/.github/workflows/pythonpackage_future3.yml index 757edb6f8..48e27b15d 100644 --- a/.github/workflows/pythonpackage_future3.yml +++ b/.github/workflows/pythonpackage_future3.yml @@ -34,8 +34,6 @@ jobs: sudo apt-get update sudo apt-get install -y libasound2-dev pulseaudio python3 -m pip install --upgrade pip - pip3 install wheel - pip3 install spidev pip3 install -r requirements.txt # For operation of the Jukebox, ZMQ must be compiled from sources due to Websocket support # Also install all optional dependencies diff --git a/docker/armv7/jukebox.Dockerfile b/docker/armv7/jukebox.Dockerfile index a0e872325..d81c447de 100644 --- a/docker/armv7/jukebox.Dockerfile +++ b/docker/armv7/jukebox.Dockerfile @@ -25,11 +25,10 @@ RUN apt-get update && apt-get install -qq -y \ --allow-downgrades --allow-remove-essential --allow-change-held-packages \ at wget gcc \ mpc mpg123 git ffmpeg spi-tools netcat alsa-tools \ - python3 python3-venv python3-dev python3-pip python3-setuptools python3-mutagen python3-gpiozero + python3 python3-venv python3-dev python3-mutagen #samba samba-common-bin #raspberrypi-kernel-headers #resolvconf -#python3-spidev # Install Jukebox # Install libzmq with Websocket support from pre-compiled source @@ -57,7 +56,7 @@ RUN mkdir -p ${ZMQ_TMP_DIR} && cd ${ZMQ_TMP_DIR}; \ # zeromq-${ZMQ_VERSION}/configure --prefix=${ZMQ_PREFIX} --enable-drafts; \ # make && make install; -ENV VIRTUAL_ENV=/opt/venv +ENV VIRTUAL_ENV=${INSTALLATION_PATH}/.venv RUN python3 -m venv $VIRTUAL_ENV ENV PATH="$VIRTUAL_ENV/bin:$PATH" diff --git a/docker/jukebox.Dockerfile b/docker/jukebox.Dockerfile index a455ec9d2..5e7a08915 100644 --- a/docker/jukebox.Dockerfile +++ b/docker/jukebox.Dockerfile @@ -25,9 +25,9 @@ RUN apt-get update && apt-get install -qq -y \ --allow-downgrades --allow-remove-essential --allow-change-held-packages \ gcc at wget \ espeak mpc mpg123 git ffmpeg spi-tools netcat \ - python3 python3-venv python3-dev python3-pip python3-mutagen python3-gpiozero + python3 python3-venv python3-dev python3-mutagen -ENV VIRTUAL_ENV=/opt/venv +ENV VIRTUAL_ENV=${INSTALLATION_PATH}/.venv RUN python3 -m venv $VIRTUAL_ENV ENV PATH="$VIRTUAL_ENV/bin:$PATH" diff --git a/documentation/content/developers/development-environment.md b/documentation/content/developers/development-environment.md index 44b748ebb..62eaeaec6 100644 --- a/documentation/content/developers/development-environment.md +++ b/documentation/content/developers/development-environment.md @@ -50,8 +50,7 @@ developing. The jukebox also runs on any Linux machine. The Raspberry Pi specific stuff will not work of course. That is no issue depending our your -development area. USB RFID Readers, however, will work. You may setup a -Python virtual environment or a conda virtual environment. You will have +development area. USB RFID Readers, however, will work. You will have to install and configure [MPD (Music Player Daemon)](https://www.musicpd.org/). diff --git a/installation/includes/00_constants.sh b/installation/includes/00_constants.sh index f643cdc47..e19dd1327 100644 --- a/installation/includes/00_constants.sh +++ b/installation/includes/00_constants.sh @@ -1,7 +1,7 @@ RPI_BOOT_CONFIG_FILE="/boot/config.txt" SHARED_PATH="${INSTALLATION_PATH}/shared" SETTINGS_PATH="${SHARED_PATH}/settings" -SYSTEMD_USR_PATH="/usr/lib/systemd/user/" +SYSTEMD_USR_PATH="/usr/lib/systemd/user" # The default upstream user, release branch, and develop branch # These are used to prepare the repo for developers diff --git a/installation/routines/setup_jukebox_core.sh b/installation/routines/setup_jukebox_core.sh index ab5f0a9bd..e6dfa6d8f 100644 --- a/installation/routines/setup_jukebox_core.sh +++ b/installation/routines/setup_jukebox_core.sh @@ -19,12 +19,11 @@ echo " -------------------------------------------------------------------- # Functions _jukebox_core_install_os_dependencies() { - echo "Install Jukebox OS dependencies" - sudo apt-get -y update; sudo apt-get -y install \ + echo " Install Jukebox OS dependencies" + sudo apt-get -y update && sudo apt-get -y install \ at \ alsa-utils \ - python3 python3-venv python3-dev python3-pip python3-setuptools \ - python3-rpi.gpio python3-gpiozero \ + python3 python3-venv python3-dev \ espeak ffmpeg mpg123 \ pulseaudio pulseaudio-module-bluetooth pulseaudio-utils caps \ libasound2-dev \ @@ -32,13 +31,19 @@ _jukebox_core_install_os_dependencies() { --allow-downgrades \ --allow-remove-essential \ --allow-change-held-packages +} + +_jukebox_core_install_python_requirements() { + echo " Install Python requirements" - VIRTUAL_ENV="${HOME_PATH}/.venv" + cd "${INSTALLATION_PATH}" || exit_on_error + + VIRTUAL_ENV="${INSTALLATION_PATH}/.venv" python3 -m venv $VIRTUAL_ENV - PATH="$VIRTUAL_ENV/bin:$PATH" source "$VIRTUAL_ENV/bin/activate" pip install --upgrade pip + pip install --no-cache-dir -r "${INSTALLATION_PATH}/requirements.txt" } _jukebox_core_configure_pulseaudio() { @@ -111,12 +116,6 @@ _jukebox_core_build_and_install_pyzmq() { fi } -_jukebox_core_install_python_requirements() { - echo " Install requirements" - cd "${INSTALLATION_PATH}" || exit_on_error - pip install --no-cache-dir -r "${INSTALLATION_PATH}/requirements.txt" -} - _jukebox_core_install_settings() { echo " Register Jukebox settings" cp -f "${INSTALLATION_PATH}/resources/default-settings/jukebox.default.yaml" "${SETTINGS_PATH}/jukebox.yaml" @@ -125,8 +124,11 @@ _jukebox_core_install_settings() { _jukebox_core_register_as_service() { echo " Register Jukebox Core user service" - sudo cp -f "${INSTALLATION_PATH}/resources/default-services/jukebox-daemon.service" "${SYSTEMD_USR_PATH}" - sudo chmod 644 "${SYSTEMD_USR_PATH}/jukebox-daemon.service" + + local jukebox_service="${SYSTEMD_USR_PATH}/jukebox-daemon.service" + sudo cp -f "${INSTALLATION_PATH}/resources/default-services/jukebox-daemon.service" "${jukebox_service}" + sudo sed -i "s|%%INSTALLATION_PATH%%|${INSTALLATION_PATH}|g" "${jukebox_service}" + sudo chmod 644 "${jukebox_service}" systemctl --user daemon-reload systemctl --user enable jukebox-daemon.service @@ -136,8 +138,8 @@ setup_jukebox_core() { echo "Install Jukebox Core" | tee /dev/fd/3 _jukebox_core_install_os_dependencies - _jukebox_core_configure_pulseaudio _jukebox_core_install_python_requirements + _jukebox_core_configure_pulseaudio _jukebox_core_build_and_install_pyzmq _jukebox_core_install_settings _jukebox_core_register_as_service diff --git a/installation/routines/setup_jukebox_webapp.sh b/installation/routines/setup_jukebox_webapp.sh index a2f9e014a..a0e195622 100644 --- a/installation/routines/setup_jukebox_webapp.sh +++ b/installation/routines/setup_jukebox_webapp.sh @@ -32,10 +32,12 @@ _jukebox_webapp_install_node() { else # install NodeJS and npm as recommended in # https://github.com/nodesource/distributions + sudo apt-get install -y ca-certificates curl gnupg + sudo mkdir -p /etc/apt/keyrings curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list sudo apt-get update - sudo apt-get install nodejs npm -y + sudo apt-get install -y nodejs fi fi diff --git a/installation/routines/setup_mpd.sh b/installation/routines/setup_mpd.sh index b3a1c3473..6b72b5f9a 100644 --- a/installation/routines/setup_mpd.sh +++ b/installation/routines/setup_mpd.sh @@ -36,7 +36,7 @@ setup_mpd() { local MPD_EXECUTE_INSTALL=true - if [[ -f ${MPD_CONF_PATH} || -f ${SYSTEMD_PATH}/mpd.service ]]; then + if [[ -f ${MPD_CONF_PATH} || -f ${SYSTEMD_USR_PATH}/mpd.service ]]; then echo " It seems there is a MPD already installed." echo " Note: It is important that MPD runs as a user service!" echo " Would you like to overwrite your configuration? [Y/n] " | tee /dev/fd/3 diff --git a/requirements.txt b/requirements.txt index 1d9e9ae83..f9f452799 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,9 @@ +# Common python packages +# You need to install these with `python -m pip install --no-cache-dir -r requirements.txt` + +setuptools +wheel + # Note: # sudo apt install libasound2-dev required on some machines @@ -13,10 +19,9 @@ requests # For the publisher event reactor loop: tornado -# RPi's GPIO packages: these are installed via APT on the PI -# On regular machines, install them manually if needed for development -# RPi.GPIO -# gpiozero +# RPi's GPIO packages: +RPi.GPIO +gpiozero # PyZMQ is a special case: # On the PI, it needs to be compiled with special options to enable Websocket support @@ -28,4 +33,3 @@ tornado flake8>=4.0.0 pytest mock - diff --git a/resources/default-services/jukebox-daemon.service b/resources/default-services/jukebox-daemon.service index f2557480e..050897e14 100644 --- a/resources/default-services/jukebox-daemon.service +++ b/resources/default-services/jukebox-daemon.service @@ -10,8 +10,8 @@ After=network.target sound.target mpd.service pulseaudio.service Requires=mpd.service pulseaudio.service [Service] -WorkingDirectory=/home/pi/RPi-Jukebox-RFID/src/jukebox -ExecStart=/bin/bash -c 'source /home/pi/.venv/bin/activate && /home/pi/.venv/bin/python run_jukebox.py' +WorkingDirectory=%%INSTALLATION_PATH%%/src/jukebox +ExecStart=/bin/bash -c 'source %%INSTALLATION_PATH%%/.venv/bin/activate && python run_jukebox.py' StandardOutput=inherit StandardError=inherit Restart=always diff --git a/src/jukebox/components/rfid/configure/__init__.py b/src/jukebox/components/rfid/configure/__init__.py index bf8dec4a9..7f9e232f2 100755 --- a/src/jukebox/components/rfid/configure/__init__.py +++ b/src/jukebox/components/rfid/configure/__init__.py @@ -26,13 +26,6 @@ def reader_install_dependencies(reader_path: str, dependency_install: str) -> No if os.path.exists(reader_path + '/requirements.txt'): # The python dependencies (if any) print("\nInstalling/Checking Python dependencies ...\n") - print("IMPORTANT for developers: Python dependencies will be installed using " - " $ pip install --upgrade -r requirements.txt'\n" - " i.e. on system level. This is target for the default RPI setup. " - "If you do not want that, but rather have them in a local or virtual environment, " - "hit No here and manually install the dependencies from your virtual environment\n" - " $ pip install --upgrade -r requirements.txt'\n" - "It is no problem to install them after running this script.\n\n") if dependency_install == 'auto' or pyil.input_yesno("Install Python dependencies?", blank=True, prompt_color=Colors.lightgreen, prompt_hint=True): print(f"{'=' * 80}") diff --git a/src/jukebox/jukebox/multitimer.py b/src/jukebox/jukebox/multitimer.py index 455b8ba75..b03aae83f 100644 --- a/src/jukebox/jukebox/multitimer.py +++ b/src/jukebox/jukebox/multitimer.py @@ -249,6 +249,7 @@ def start(self, iterations=None, wait_seconds_per_iteration=None): self._function = self._callee(*self.class_args, iterations=self._iterations, **self.class_kwargs) super().start(wait_seconds_per_iteration) + @plugin.tag def get_state(self): return {'enabled': self.is_alive(), 'wait_seconds_per_iteration': self.get_timeout(),