Skip to content

Commit

Permalink
better linux support?
Browse files Browse the repository at this point in the history
  • Loading branch information
elibroftw committed Mar 15, 2024
1 parent 752ebec commit 1434c36
Show file tree
Hide file tree
Showing 9 changed files with 175 additions and 7 deletions.
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions linux_install.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 25 additions & 0 deletions scripts/arch-install.sh
Original file line number Diff line number Diff line change
@@ -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"
29 changes: 29 additions & 0 deletions scripts/debian-install.sh
Original file line number Diff line number Diff line change
@@ -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"
24 changes: 24 additions & 0 deletions scripts/fedora-install.sh
Original file line number Diff line number Diff line change
@@ -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"
48 changes: 48 additions & 0 deletions scripts/pre-req.sh
Original file line number Diff line number Diff line change
@@ -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
24 changes: 24 additions & 0 deletions scripts/suse-install.sh
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 1434c36

Please sign in to comment.