Skip to content

Commit

Permalink
Cleanup and stuff (#1330)
Browse files Browse the repository at this point in the history
* compile-phazor.sh: Removed.

It's not gonna be needed on next releases, process is being merged
through pyproject.toml.

* compile-phazor-pipewire.sh: Removed.

It's not gonna be needed on next releases, process is being merged
through pyproject.toml.

* hard_fix: Added (Experimental for now).

The main idea, might adjust it accordingly later.

* win-build.sh: Removed.

Will be moved to run.sh

* run.sh: Squashed.

This is all in one script, used to be several, now just choose each
one that's required for the scenario.

Signed-off-by: Pouria Rezaei <[email protected]>

---------

Signed-off-by: Pouria Rezaei <[email protected]>
  • Loading branch information
RSKYS authored Dec 5, 2024
1 parent d154656 commit 3617679
Show file tree
Hide file tree
Showing 6 changed files with 131 additions and 102 deletions.
10 changes: 0 additions & 10 deletions compile-phazor-pipewire.sh

This file was deleted.

10 changes: 0 additions & 10 deletions compile-phazor.sh

This file was deleted.

16 changes: 16 additions & 0 deletions hard_fix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# This is still just a main idea, nothing much's going on.
"""Applies the patch for less warns on official releases."""
import logging
import subprocess


def main() -> None:
try:
logging.info("Attempting to apply MA/KF patch...")
subprocess.run("patch -Np1 < extra/pyinstaller-hooks/bla.diff", shell=True, check=True)
except subprocess.CalledProcessError as e:
logging.warning(f"Patch application failed: {e}. Proceeding with the build.")
pass

if __name__ == "__main__":
main()
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
[project.entry-points."distutils.commands"]
compile_translations = "compile_translations:main"

#hard_fix = "hard_fix:main"
## Note that if above goes to main, it should get done before phazor compiler.

[project.urls]
homepage = "https://tauonmusicbox.rocks/"

Expand Down
141 changes: 112 additions & 29 deletions run.sh
Original file line number Diff line number Diff line change
@@ -1,37 +1,120 @@
#!/usr/bin/env bash

set -euo pipefail

# Ensure correct cwd, for example: ~/Projects/Tauon
cd "$(dirname "$0")"
win_build() {
rm -rf dist/tauon

export PYTHONPATH=".":"${PYTHONPATH-}"
# TODO(Martin): pkg_resources is deprecated, does it still need to be there?
# https://setuptools.pypa.io/en/latest/pkg_resources.html
pyinstaller \
--additional-hooks-dir='extra\pyinstaller-hooks' \
--hidden-import 'infi.systray' \
--hidden-import 'pylast' \
--hidden-import 'tekore' \
--add-binary 'C:\msys64\mingw64\lib\girepository-1.0\Rsvg-2.0.typelib;gi_typelibs' \
--add-binary 'lib/libphazor.so;lib' \
--add-binary 'C:\msys64\mingw64\bin\libFLAC.dll;.' \
--add-binary 'C:\msys64\mingw64\bin\libmpg123-0.dll;.' \
--add-binary 'C:\msys64\mingw64\bin\libogg-0.dll;.' \
--add-binary 'C:\msys64\mingw64\bin\libopenmpt-0.dll;.' \
--add-binary 'C:\msys64\mingw64\bin\libopus-0.dll;.' \
--add-binary 'C:\msys64\mingw64\bin\libopusfile-0.dll;.' \
--add-binary 'C:\msys64\mingw64\bin\libsamplerate-0.dll;.' \
--add-binary 'C:\msys64\mingw64\bin\libvorbis-0.dll;.' \
--add-binary 'C:\msys64\mingw64\bin\libvorbisfile-3.dll;.' \
--add-binary 'C:\msys64\mingw64\bin\libwavpack-1.dll;.' \
--add-binary 'C:\msys64\mingw64\bin\SDL2.dll;.' \
--add-binary 'C:\msys64\mingw64\bin\SDL2_image.dll;.' \
--add-binary 'C:\msys64\mingw64\bin\libgme.dll;.' \
--hidden-import 'pip' \
--hidden-import 'packaging.requirements' \
--hidden-import 'pkg_resources.py2_warn' \
--hidden-import 'requests' \
src/tauon/tauon.py \
-w -i assets/icon.ico

rm -rf .venv build dist tauon_music_box.egg-info src/phazor/kissfft src/phazor/miniaudio
mkdir -p src/phazor/kissfft src/phazor/miniaudio
mkdir -p dist/tauon/tekore
mkdir -p dist/tauon/etc

_kissfftver=131.1.0
_miniaudiocommit=4a5b74bef029b3592c54b6048650ee5f972c1a48
if [[ ! -e kissfft.tar.gz ]]; then
curl -L -o kissfft.tar.gz "https://github.com/mborgerding/kissfft/archive/refs/tags/${_kissfftver}.tar.gz"
fi
if [[ ! -e miniaudio.tar.gz ]]; then
curl -L -o miniaudio.tar.gz "https://github.com/mackron/miniaudio/archive/${_miniaudiocommit}.tar.gz"
#cp C:/msys64/mingw64/lib/python3.13/site-packages/tekore/VERSION dist/tauon/tekore/VERSION

cp -r src/tauon/{theme,assets,locale,templates,lib} dist/tauon/
rm -rf dist/tauon/share/{icons,locale,tcl/tzdata} dist/tauon/tcl/tzdata
cp -r fonts dist/tauon/ || echo 'Fonts are not present!'
cp -r /mingw64/etc/fonts dist/tauon/etc
cp librespot.exe dist/tauon/
cp TaskbarLib.tlb dist/tauon/ || echo 'TLB is not present!'
}


main() {
# Ensure correct cwd, for example: ~/Projects/Tauon
cd "$(dirname "$0")"
export PYTHONPATH=".":"${PYTHONPATH-}"

rm -rf .venv build dist tauon_music_box.egg-info src/phazor/{kissfft,miniaudio}
mkdir -p src/phazor/{kissfft,miniaudio}

_kissfftver=131.1.0
_miniaudiocommit=4a5b74bef029b3592c54b6048650ee5f972c1a48

[[ ! -e kissfft.tar.gz ]] && curl -L -o kissfft.tar.gz "https://github.com/mborgerding/kissfft/archive/refs/tags/${_kissfftver}.tar.gz"
[[ ! -e miniaudio.tar.gz ]] && curl -L -o miniaudio.tar.gz "https://github.com/mackron/miniaudio/archive/${_miniaudiocommit}.tar.gz"

tar --strip-components=1 -xvf kissfft.tar.gz -C ./src/phazor/kissfft/
tar --strip-components=1 -xvf miniaudio.tar.gz -C ./src/phazor/miniaudio/

python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt requirements_optional.txt requirements_devel.txt build
python -m compile_translations
python -m build --wheel
pip install --prefix ".venv" dist/*.whl --force-reinstall
}


compile_phazor() {
gcc src/phazor/kissfft/kiss_fftr.c src/phazor/kissfft/kiss_fft.c src/phazor/phazor.c \
$(pkg-config --cflags --libs python3 samplerate wavpack opusfile vorbisfile libmpg123 flac libopenmpt libgme) \
-shared -o libphazor.so -fPIC -Wall -O3 -g

mkdir -p build
mv libphazor.so build/libphazor.so
}


compile_phazor_pipewire() {
gcc src/phazor/kissfft/kiss_fftr.c src/phazor/kissfft/kiss_fft.c src/phazor/phazor.c \
$(pkg-config --cflags --libs python3 samplerate wavpack opusfile vorbisfile libmpg123 flac libopenmpt libgme libpipewire-0.3) \
-shared -o libphazor-pw.so -fPIC -Wall -O3 -g -DPIPE

mkdir -p build
mv libphazor-pw.so build/libphazor-pw.so
}

# Display menu
show_menu() {
echo -e "\n\
Select a script to run:\n\
1. Setup Env and Install\n\
2. Build for Windows\n\
Enter the number of the script to run:"
read -r choose
}

if [[ $# -eq 0 ]]; then
show_menu
else
choose=$1
fi

tar --strip-components=1 -xvf kissfft.tar.gz -C ./src/phazor/kissfft/
tar --strip-components=1 -xvf miniaudio.tar.gz -C ./src/phazor/miniaudio/

python -m venv .venv
# Windows: .\.venv\Scripts\activate
source .venv/bin/activate
pip install -r requirements.txt
pip install -r requirements_optional.txt
pip install -r requirements_devel.txt
#pip install -r requirements_windows.txt
pip install build
python -m compile_translations
python -m build --wheel
#python -m installer --destdir=".venv" dist/*.whl
pip install --prefix ".venv" dist/*.whl --force-reinstall

tauonmb "$@"
case $choose in
1) main ;;
2) win_build ;;
pwr) compile_phazor ;;
pwp) compile_phazor_pipewire ;;
*) echo -e "\n\
Invalid option!\n\
Please select 1, 2, pwr(dev), or pwp(dev)." ;;
esac
53 changes: 0 additions & 53 deletions win-build.sh

This file was deleted.

0 comments on commit 3617679

Please sign in to comment.