From 1434c36629fbb5cc7ef06c45d24c5d7542aa7b3f Mon Sep 17 00:00:00 2001 From: Elijah Lopez Date: Thu, 14 Mar 2024 21:56:34 -0400 Subject: [PATCH] better linux support? --- Dockerfile | 16 +++++++++++++ README.md | 4 +--- linux_install.sh | 9 +++++--- requirements.txt | 3 ++- scripts/arch-install.sh | 25 ++++++++++++++++++++ scripts/debian-install.sh | 29 +++++++++++++++++++++++ scripts/fedora-install.sh | 24 ++++++++++++++++++++ scripts/pre-req.sh | 48 +++++++++++++++++++++++++++++++++++++++ scripts/suse-install.sh | 24 ++++++++++++++++++++ 9 files changed, 175 insertions(+), 7 deletions(-) create mode 100644 Dockerfile create mode 100755 scripts/arch-install.sh create mode 100755 scripts/debian-install.sh create mode 100755 scripts/fedora-install.sh create mode 100755 scripts/pre-req.sh create mode 100755 scripts/suse-install.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..84cc4a43 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +# WIP: Build an image capable of producing music-caster App Images# WIP: Build an image capable of producing music-caster App Images +# Base image: Fedora 37 +FROM fedora:37 + +# Install required tools +RUN dnf update -y && \ + dnf install -y python3.12 python3.12-devel python3.12-virtualenv dnf-plugins-core libappindicator-gtk3 && \ + dnf config-manager --set-enabled powertools && \ + dnf install -y python3-tkinter + +# Install pip for Python 3.12 (as it's not included by default) +RUN curl https://bootstrap.pypa.io/get-pip.py | python3.12 + +CMD cd /var/music-caster && \ + python3.12 -m pip install --upgrade -r requirements.txt -r requirements-dev.txt && \ + python3.12 -O -m PyInstaller --onefile build_files/onedir.spec diff --git a/README.md b/README.md index 73852fce..2bab85b4 100644 --- a/README.md +++ b/README.md @@ -31,12 +31,10 @@ Unique users as of April 23rd 2023: 3,800 Not maintained, but I did get it to work on Ubuntu once. Music Caster is not straight forward to package, so you can invoke a sudo-free [install script](linux_install.sh). -Make sure you have `python3.12`+, `pip`, `tkinter`, and `python3-venv` installed before running the commands below. - ```bash mkdir -p ~/bin && git clone --depth 1 https://github.com/elibroftw/music-caster.git ~/bin/music-caster cd ~/bin/music-caster -./linux_install.sh +./linux_install.sh # use sudo for non-interactive install in case a dependency needs to be installed ``` ## Demo diff --git a/linux_install.sh b/linux_install.sh index abbaf70e..f475f6af 100755 --- a/linux_install.sh +++ b/linux_install.sh @@ -1,10 +1,13 @@ #!/usr/bin/env bash set -ex -# cd ~/bin/music-caster + echo "(music-caster) Updating..." -git fetch -git reset --hard "@{u}" +# git fetch +# git reset --hard "@{u}" + PYTHON=python3.12 +./scripts/pre-req.sh $PYTHON + echo "(music-caster) Creating $PYTHON virtual environment" # if .venv DNE or has wrong Python version, delete old .venv and install new .venv if [ ! -d .venv ] || [ "$(.venv/bin/python -V)" != "$($PYTHON -V)" ]; then diff --git a/requirements.txt b/requirements.txt index be4ffa13..98637c6b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -25,7 +25,8 @@ pyperclip~=1.8 https://github.com/yt-dlp/yt-dlp/archive/master.tar.gz werkzeug~=3.0 python-vlc==3.0.20123 -lz4==3.1.3 +lz4==3.1.3; sys_platform == 'win32' +lz4; sys_platform != 'win32' browser_cookie3 beautifulsoup4~=4.10 flask~=2.0 diff --git a/scripts/arch-install.sh b/scripts/arch-install.sh new file mode 100755 index 00000000..3b48c554 --- /dev/null +++ b/scripts/arch-install.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +echo "arch-based distro detected" +PYTHON=$1 + +# Check for python3.12 +if ! pacman -Q "$PYTHON" &> /dev/null; then + echo "$PYTHON not found. Installing..." + sudo pacman -Sy --noconfirm "$PYTHON" "$PYTHON-dev" "$PYTHON-virtualenv" "$PYTHON-tk" +fi + +# Check for pip +if ! $PYTHON -m pip --version &> /dev/null; then + echo "pip not found. Installing..." + sudo pacman -Sy --noconfirm python-pip +fi + +# Check for tkinter +if ! $PYTHON -c "import tkinter" &> /dev/null; then + echo "tkinter not found. Installing..." + sudo pacman -Sy --noconfirm $PYTHON-tk +fi + +# Check for python3-venv +echo "Ensuring $PYTHON-virtualenv is insalled" +sudo pacman -Sy --noconfirm "$PYTHON-virtualenv" diff --git a/scripts/debian-install.sh b/scripts/debian-install.sh new file mode 100755 index 00000000..7b01c3b7 --- /dev/null +++ b/scripts/debian-install.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +echo "debian-based distro detected" +PYTHON=$1 +# sudo apt install -y software-properties-common +# Check for python3.12 +if ! $PYTHON --version &> /dev/null; then + echo "Python 3.12 not found. Installing..." + sudo add-apt-repository -y ppa:deadsnakes/ppa + sudo apt update + sudo apt install -y python3.12 "${PYTHON}-venv" "${PYTHON}-tk" +fi + +# Check for pip +if ! $PYTHON -m pip --version &> /dev/null; then + echo "pip not found. Installing..." + sudo apt update + sudo apt install -y python3-pip +fi + +# Check for tkinter +if ! $PYTHON -c "import tkinter" &> /dev/null; then + echo "tkinter not found. Installing..." + sudo apt update + sudo apt install -y "${PYTHON}-tk" +fi + +echo "Ensuring $PYTHON-venv is insalled" +sudo apt update +sudo apt install -y "${PYTHON}-venv" diff --git a/scripts/fedora-install.sh b/scripts/fedora-install.sh new file mode 100755 index 00000000..a432825d --- /dev/null +++ b/scripts/fedora-install.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +echo "fedora-based distro detected" +PYTHON=$1 + +# Check for $PYTHON +if ! dnf list installed "$PYTHON" &> /dev/null; then + echo "$PYTHON not found. Installing..." + sudo dnf install -y "$PYTHON" "$PYTHON-devel" "$PYTHON-virtualenv" +fi + +# Check for pip +if ! $PYTHON -m pip --version &> /dev/null; then + echo "pip not found. Installing..." + sudo dnf install -y python-pip +fi + +# Check for tkinter +if ! "$PYTHON" -c "import tkinter" &> /dev/null; then + echo "tkinter not found. Installing..." + sudo dnf install -y "$PYTHON-tkinter" +fi + +echo "Ensuring $PYTHON-virtualenv is insalled" +sudo dnf install -y "$PYTHON-virtualenv" diff --git a/scripts/pre-req.sh b/scripts/pre-req.sh new file mode 100755 index 00000000..5f25671b --- /dev/null +++ b/scripts/pre-req.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash +# Define script locations (change paths if needed) +DEBIAN_INSTALL="./scripts/debian-install.sh" +ARCH_INSTALL="./scripts/arch-install.sh" +FEDORA_INSTALL="./scripts/fedora-install.sh" +SUSE_INSTALL="./scripts/suse-install.sh" +# Check for /etc/os-release (preferred method) +if [ -f /etc/os-release ]; then + . /etc/os-release + case "$ID" in + debian|ubuntu|mint|linuxmint) + if [ -f "$DEBIAN_INSTALL" ]; then + "$DEBIAN_INSTALL" "$1" + exit 0 + fi + echo "Error: $DEBIAN_INSTALL not found!" + exit 1 + ;; + arch) + if [ -f "$ARCH_INSTALL" ]; then + "$ARCH_INSTALL" "$1" + exit 0 + fi + echo "Error: $ARCH_INSTALL not found!" + exit 1 + ;; + fedora) + if [ -f "$FEDORA_INSTALL" ]; then + "$FEDORA_INSTALL" "$1" + exit 0 + fi + echo "Error: $FEDORA_INSTALL not found!" + exit 1 + ;; + opensuse|sles) + if [ -f "$SUSE_INSTALL" ]; then + "$SUSE_INSTALL" "$1" + exit 0 + fi + echo "Error: $SUSE_INSTALL not found!" + exit 1 + ;; + esac +fi + +# No match, display error +echo "Error: Unsupported distribution. Only Debian, Arch, Fedora, and SUSE are supported." +exit 1 diff --git a/scripts/suse-install.sh b/scripts/suse-install.sh new file mode 100755 index 00000000..fe91e63c --- /dev/null +++ b/scripts/suse-install.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +echo "suse-based distro detected" +PYTHON=$1 + +# Check for $PYTHON +if ! zypper info "$PYTHON" &> /dev/null; then + echo "$PYTHON not found. Installing..." + sudo zypper install -y "$PYTHON" "$PYTHON-devel" "$PYTHON-virtualenv" +fi + +# Check for pip +if ! $PYTHON -m pip --version &> /dev/null; then + echo "pip not found. Installing..." + sudo zypper install -y "$PYTHON-pip" +fi + +# Check for tkinter +if ! "$PYTHON" -c "import tkinter" &> /dev/null; then + echo "tkinter not found. Installing..." + sudo zypper install -y "$PYTHON-tk" +fi + +echo "Ensuring $PYTHON-virtualenv is insalled" +sudo zypper install -y "$PYTHON-virtualenv"