Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix up macOS and Windows builds #1352

Merged
merged 45 commits into from
Dec 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
859bb2d
Convert phazor to tabs, fix indents, add indents for ifdefs, add ming…
C0rn3j Dec 20, 2024
bca1533
Fix typo
C0rn3j Dec 20, 2024
85081ff
Fix opencc optdep
C0rn3j Dec 20, 2024
717b2c4
run.sh: Don't install _optional.txt, it's already included
C0rn3j Dec 20, 2024
48d1699
myspac.txt: Add mingw-w64-x86_64-rust for pydantic source builds
C0rn3j Dec 20, 2024
b827356
Indent couple missed ifdefs
C0rn3j Dec 20, 2024
785d783
Try adding /mingw64/include/
C0rn3j Dec 20, 2024
3e72270
Pillow is needed on all platforms
C0rn3j Dec 20, 2024
8ae9cb8
Move requirements for specific OSs and opts to extra as requirements.…
C0rn3j Dec 21, 2024
b04c0d4
macOS CI: Use develop pyinstaller as the fix is now in master
C0rn3j Dec 21, 2024
42474ce
run.sh: Check python silently and in a function
C0rn3j Dec 21, 2024
9adf0a5
run.sh: Fix up script path for Windows build and remove Rsvg typelib …
C0rn3j Dec 21, 2024
dddbdc1
run.sh: Fix building Pillow on MINGW
C0rn3j Dec 21, 2024
b63169d
Phazor: Add .pyd for Windows DLLs and cleanup pyproject.toml comments
C0rn3j Dec 21, 2024
09f99d3
Phazor: Fix dosctring
C0rn3j Dec 21, 2024
0f11942
Fix more docstrings
C0rn3j Dec 21, 2024
09bd82a
Touch up error text
C0rn3j Dec 21, 2024
04ff3e4
Use is_file()
C0rn3j Dec 21, 2024
f02ee63
phazor.c: Add missing space
C0rn3j Dec 21, 2024
9c0f482
phazor.c: Format code better
C0rn3j Dec 21, 2024
fbec990
run.sh: Better note
C0rn3j Dec 21, 2024
aba27eb
pyproject.toml: Fix broken opus include on Windows
C0rn3j Dec 21, 2024
deb593f
Init windows.spec
C0rn3j Dec 21, 2024
8d82244
windows.spec: Fix phazor
C0rn3j Dec 21, 2024
05762db
windows.spec: Fix icons
C0rn3j Dec 21, 2024
296af78
windows.spec: Stop copying lib dir and add note about Defender
C0rn3j Dec 21, 2024
190591d
windows.spec: Make librespot optional in run.sh
C0rn3j Dec 21, 2024
9213915
windows.spec: Add --noconfirm to pyinstaller
C0rn3j Dec 21, 2024
f520a30
windows.spec: Name TauonMusicBox
C0rn3j Dec 21, 2024
e434bfb
windows.spec: Set scriptname and nicer file copying
C0rn3j Dec 21, 2024
bd4d3b8
windows.spec: Yeet scriptname
C0rn3j Dec 21, 2024
ad56f61
windows.spec: Small touchup
C0rn3j Dec 21, 2024
7400dcc
main: add spaces to the correct place in the string
C0rn3j Dec 21, 2024
35fe272
Add (optimistic) changelog entry to not have to fix it later again
C0rn3j Dec 21, 2024
87990fd
phazor.c: Leave Python.h stuff only for MSVC
C0rn3j Dec 21, 2024
b20cbb3
Revert ifdefing python.h and migrate to WIN64 and __MINGW64__ ifdefs
C0rn3j Dec 21, 2024
cd9b4f8
main: Do not attempt to load nonexistent file
C0rn3j Dec 21, 2024
6a86fef
Fix Path function name
C0rn3j Dec 21, 2024
caadea5
test phazor EXPORTs
C0rn3j Dec 21, 2024
2755bd1
phazor: Mark functions explicitly exported for Windows
C0rn3j Dec 21, 2024
e5d63c0
Fix up linebreaks
C0rn3j Dec 21, 2024
bdd9844
scan_devices is supposed to be exported
C0rn3j Dec 21, 2024
d67cf16
run.sh: Remove redundant comment
C0rn3j Dec 21, 2024
e8b0f73
Note portable installation directory change in changelog
C0rn3j Dec 21, 2024
de81625
changelog: Remove newline that made the bulletpoints space more than …
C0rn3j Dec 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build_macOS.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ jobs:
pip install \
-r requirements.txt \
build
# Hack until https://github.com/pyinstaller/pyinstaller/issues/8936 is resolved
pip install https://github.com/rokm/pyinstaller/archive/refs/heads/macos-nested-framework-bundles.zip
# Hack until pyinstaller has a release newer than 6.11.1 - https://github.com/pyinstaller/pyinstaller/releases
pip install https://github.com/pyinstaller/pyinstaller/archive/develop.zip
# \
# pyinstaller
# pip uninstall pyinstaller
Expand Down
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ Changelog
### v7.9.0

- **Added** TIDAL support
- **Added** macOS (experimental) and Linux automated CI builds
- **Changed** portable installations now save `cache` and `user-data` directiories in `src/tauon/`, move existing directories there if necessary
- **Fixed** Windows support
- **Fixed** crashes related to PipeWire [#1250](https://github.com/Taiko2k/Tauon/issues/1250)
- **Fixed** audio cutting out on the PipeWire backend with specific custom quantum settings [#1245](https://github.com/Taiko2k/Tauon/issues/1245)
- **Fixed** wrong encoding used for some tags in XSPF exports [#1331](https://github.com/Taiko2k/Tauon/issues/1331)
Expand All @@ -17,7 +20,6 @@ Changelog
- **Improved** Various changes to build system, Migrated to pyproject.toml
- ***Removed*** guitar chords feature - api.guitarchords.com it partially relied on is dead, replaced by newer API that would need implementing, and the chords feature was unmaintained
- ***Removed*** Spotify recommendations feature (API deprecated by Spotify)

- Many other bug fixes and code refactors [Special thanks to @C0rn3j for a lot of these]

### v7.8.3
Expand Down
9 changes: 5 additions & 4 deletions extra/msyspac.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
mingw-w64-x86_64-SDL2
mingw-w64-x86_64-SDL2_image
mingw-w64-x86_64-flac
mingw-w64-x86_64-gcc
mingw-w64-x86_64-gtk3
mingw-w64-x86_64-libgme
mingw-w64-x86_64-libopenmpt
mingw-w64-x86_64-libsamplerate
mingw-w64-x86_64-opusfile
mingw-w64-x86_64-pkgconf
mingw-w64-x86_64-wavpack
mingw-w64-x86_64-python3
mingw-w64-x86_64-python3-gobject
mingw-w64-x86_64-python3-pillow
mingw-w64-x86_64-python3-pip
mingw-w64-x86_64-python-websocket-client
mingw-w64-x86_64-libgme
mingw-w64-x86_64-rust
mingw-w64-x86_64-SDL2
mingw-w64-x86_64-SDL2_image
mingw-w64-x86_64-wavpack
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ colored_traceback
jxlpy; sys_platform != 'darwin' # macOS hates it - fails to find jxl/types.h - https://github.com/olokelo/jxlpy/issues/25#issuecomment-2547928563
#librespot - https://github.com/kokarare1212/librespot-python/pull/286
natsort
opencc
opencc; sys_platform != 'win32'
opencc-python-reimplemented; sys_platform == 'win32'
#picard - picard 2.12.3 requires charset-normalizer~=3.3.2, but you have charset-normalizer 3.4.0 which is incompatible.
plexapi
PyChromecast
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ musicbrainzngs
mutagen
natsort # optdep
opencc-python-reimplemented # Windows version of openCC optdep
Pillow
PlexAPI
PyGObject
pyinstaller
Expand Down
12 changes: 4 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@
# https://setuptools.pypa.io/en/latest/userguide/ext_modules.html
# This is terribly formatted as in TOML 1.0 it all has to be inline, can only be changed when TOML 1.1 ships

# Windows - MSVC - does not work as PyGobject, GTK, Cairo and et al won't build under MVSC
# Windows (MSVC) - does not work as PyGobject, GTK, Cairo and et al won't build under MVSC
# One option would be to test https://github.com/wingtk/gvsbuild + https://stackoverflow.com/a/72737752
# ./vcpkg.exe install libsndfile:x64-windows # TODO download the necessities instead of this bundle, libflac at minimum
# ./vcpkg.exe install mpg123:x64-windows # Hack 1.29.3 in first see https://sourceforge.net/p/mpg123/bugs/374/
# ./vcpkg.exe install mpg123:x64-windows
# ./vcpkg.exe install libsamplerate:x64-windows
# ./vcpkg.exe install libopenmpt:x64-windows
# ./vcpkg.exe install wavpack:x64-windows
Expand All @@ -85,18 +85,14 @@
# ext-modules = [
# {name = "phazor", sources = ["src/phazor/kissfft/kiss_fftr.c", "src/phazor/kissfft/kiss_fft.c", "src/phazor/phazor.c"], include-dirs = ["src/phazor/miniaudio", "C:/Users/Yeet/Tauon/src/phazor/miniaudio", "C:/Users/Yeet/Tauon/vcpkg/installed/x64-windows/include", "C:/Users/Yeet/Tauon/src/phazor/kissfft", "C:/Users/Yeet/Tauon/src/phazor/miniaudio"], libraries=["samplerate", "wavpackdll", "opusfile", "ogg", "opus", "vorbisfile", "mpg123", "FLAC", "openmpt", "pthreadVC3", "gme"], library-dirs = ["vcpkg/installed/x64-windows/lib"] },]

# Linux + macOS
# Linux + macOS + Windows (MINGW64)
ext-modules = [
{name = "phazor", sources = ["src/phazor/kissfft/kiss_fftr.c", "src/phazor/kissfft/kiss_fft.c", "src/phazor/phazor.c"], include-dirs = ["/usr/include/opus", "/opt/homebrew/include/opus", "/opt/homebrew/include"], libraries = ["samplerate", "wavpack", "opusfile", "vorbisfile", "mpg123", "FLAC", "openmpt", "gme"], library-dirs = ["/opt/homebrew/lib"] },
{name = "phazor", sources = ["src/phazor/kissfft/kiss_fftr.c", "src/phazor/kissfft/kiss_fft.c", "src/phazor/phazor.c"], include-dirs = ["/usr/include/opus", "/opt/homebrew/include/opus", "/opt/homebrew/include", "C:/msys64/mingw64/include/opus"], libraries = ["samplerate", "wavpack", "opusfile", "vorbisfile", "mpg123", "FLAC", "openmpt", "gme"], library-dirs = ["/opt/homebrew/lib"] },
# Set as optional to allow soft-failure, it's expected not to build on Windows/macOS, but we don't want to fail the entire build on it
# I have not found a better way to solve this, ideally we would somehow tag this as Linux-exclusive
{name = "phazor-pw", sources = ["src/phazor/kissfft/kiss_fftr.c", "src/phazor/kissfft/kiss_fft.c", "src/phazor/phazor.c"], include-dirs = ["/usr/include/opus"], libraries = ["samplerate", "wavpack", "opusfile", "vorbisfile", "mpg123", "FLAC", "openmpt", "gme", "pipewire-0.3"], optional = true },
]

# macOS
# ext-modules = [
# {name = "phazor", sources = ["src/phazor/kissfft/kiss_fftr.c", "src/phazor/kissfft/kiss_fft.c", "src/phazor/phazor.c"], include-dirs = ["/opt/homebrew/include/opus", "src/phazor/kissfft", "/opt/homebrew/include"], libraries=["samplerate", "wavpack", "opusfile", "vorbisfile", "mpg123", "FLAC", "openmpt", "gme"], library-dirs = ["/opt/homebrew/lib"] },]

package-dir = {"" = "src"}

# Should we care about these options or is it fine to omit them here?
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pysdl2-dll # Don't rely on system SDL2 https://github.com/py-sdl/py-sdl2#require
comtypes; sys_platform == 'win32'
infi.systray; sys_platform == 'win32'
keyboard; sys_platform == 'win32'
Pillow; sys_platform != 'win32'
Pillow
opencc; sys_platform != 'win32' # OPTDEP
opencc-python-reimplemented; sys_platform == 'win32' # OPTDEP
#pyinstaller # ; sys_platform != 'linux' # for macOS at least
Expand Down
57 changes: 35 additions & 22 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@ set -euo pipefail

win_build() {
rm -rf dist/tauon
# Had to do Windows Security -> Virus & thread protection*2 -> Manage settings -> Windows Real-time protection: off

# TODO(Martin): pkg_resources is deprecated, does it still need to be there?
# https://setuptools.pypa.io/en/latest/pkg_resources.html
pyinstaller \
--name TauonMusicBox \
--noconfirm \
--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' \
--hidden-import 'phazor' \
--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;.' \
Expand All @@ -31,27 +33,40 @@ win_build() {
--hidden-import 'packaging.requirements' \
--hidden-import 'pkg_resources.py2_warn' \
--hidden-import 'requests' \
src/tauon/tauon.py \
-w -i assets/icon.ico
src/tauon/__main__.py \
-w -i src/tauon/assets/icon.ico

mkdir -p dist/tauon/tekore
mkdir -p dist/tauon/etc
mkdir -p dist/TauonMusicBox/tekore
mkdir -p dist/TauonMusicBox/etc

#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!'
cp -r src/tauon/{theme,assets,locale,templates} dist/TauonMusicBox/
rm -rf dist/tauon/share/{icons,locale,tcl/tzdata} dist/TauonMusicBox/tcl/tzdata
cp -r fonts dist/tauon/ || echo 'fonts directory is not present!'
cp -r /mingw64/etc/fonts dist/TauonMusicBox/etc
if [[ -e librespot.exe ]]; then
cp librespot.exe dist/TauonMusicBox/
else
echo 'librespot.exe is not present!'
fi
if [[ -e TaskbarLib.tlb ]]; then
cp TaskbarLib.tlb dist/TauonMusicBox/
else
echo 'TaskbarLib.tlb is not present!'
fi
echo -e "Packaged to dist/TauonMusicBox"
}

dirty_venv_run() {
if ! command -v python; then
python_check() {
if ! command -v python >/dev/null; then
echo -e "python executable not found? Is python installed? Debian(-based) distributions may need python-is-python3 installed via apt."
exit 1
fi
}

dirty_venv_run() {
python_check
# Ensure correct cwd, for example: ~/Projects/Tauon
cd "$(dirname "${0}")"
export PYTHONPATH=".":"${PYTHONPATH-}"
Expand All @@ -60,10 +75,7 @@ dirty_venv_run() {
}

clean_venv_run() {
if ! command -v python; then
echo -e "python executable not found? Is python installed? Debian(-based) distributions may need python-is-python3 installed via apt."
exit 1
fi
python_check
# Ensure correct cwd, for example: ~/Projects/Tauon
cd "$(dirname "${0}")"
export PYTHONPATH=".":"${PYTHONPATH-}"
Expand All @@ -82,14 +94,17 @@ clean_venv_run() {

python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt -r requirements_optional.txt -r requirements_devel.txt build
# python -m pip install -U pip
# Necessary for Windows (MINGW64) if compiling things like Pillow
export CFLAGS="-I/mingw64/include"
# export LDFLAGS="-L/mingw64/lib"
pip install -r requirements.txt -r requirements_devel.txt build
python -m compile_translations
python -m build --wheel
pip install --prefix ".venv" dist/*.whl --force-reinstall
tauonmb # "${@}" # Passing args is broken atm
}


compile_phazor() {
outFile="build/libphazor.so"
mkdir -p build
Expand All @@ -100,7 +115,6 @@ compile_phazor() {
echo "Compiled as ${outFile}!"
}


compile_phazor_pipewire() {
outFile="build/libphazor-pw.so"
mkdir -p build
Expand All @@ -111,7 +125,6 @@ compile_phazor_pipewire() {
echo "Compiled as ${outFile}!"
}

# Display menu
show_menu() {
PS3="Select a script to run: "
select yn in "${answer_options[@]}"; do
Expand Down
Loading
Loading