Skip to content

Commit

Permalink
CI, phazor and other misc improvements and bug fixes (Taiko2k#1361)
Browse files Browse the repository at this point in the history
* Don't repeatedly call pctl.playing_object() and verify that track is not None

* Avoid defining tidal and spot_ctl both outside the Tauon class and inside, avoids us having to check for them being None

* Tidy up code/use pathlib

* Small typing and pathlib fixes

* phazor.c: Convert "bool" to actual bool with stdbool.h

* phazor.c: Remove unused variable

* phazor: Convert more ints to bool

* phazor: Remove accidentally commited debug

* Require C17 or later and prep a future check for C23

* Remove a bunch of linebreaks

* remove old pyproject note

* Mark a couple resource leaks to deal with later

* Fix downloadS name and drop XDG music/downloads logs to debug

* Migrate from zip to 7zip

* Phazor notes

* Stop hardcoding Python ver in spec files

* Fix Windows 7z

* Attempt to remove pointless nested directories in the final archive

* Disable colored_traceback on Windows

* Add source for TaskBarLib.idl

* TBL.idl: Fix up file path

* Fix capitalization

* windows: Pack librespot.exe and TaskbarLib.tlb

* SMTC: Add missing runtimeobject.lib dependency

* Add TauonSMTC.dll to Windows CI

* pack TauonSMTC.dll to lib dir

* Add a logging TODO

* Pack fonts on Windows

* Add fonts download as comments to run.sh

* Log fonts directory

* Fix up double quotes and needless Path calls

* Add python-magic to reqs, add typing to set_rating() and remove unused old_backend variable

* Try forcing --platform=win_amd64

* Define DA_Formats more concisely

* Uh, are we using the wrong python this entire time

* Shut up pip warning

* This ain't da wae

* Use Python-magic from PR

* Avoid pyinstaller bug

* Fix a couple resource leaks

* tagscan: Add support for context managers and use them in main

* Skip Python magic on Windows entirely for now

* Revert last change, this part does work

* Linting/typing

* Bump copyright to 2025 and add some logging for SMTC

* Fix crash on exit

* Move GallClass and ThumbTracks init to Tauon class and fix leak in AlbumArt

* Fix ThumbTracks memory leak

* Remove leak TODOs as they were fixed

* Type up auto_name_pl

* Convert [install|user|config]_directory to Path

* Juggle directory logging order

* Yeet redundant Path call

* Fix locale, as it is now packaged inside of Install_directory

* myspac.txt: Add cmake

* Windows CI: Try to use the msys package list in the repo instead of duping it

* Fix for pwsh

* attempt No 3 at pwsh

* Fix msyspac.txt file name

* Add ninja to msyspac.txt

* Add base-devel to msyspac.txt

* Add mingw-w64-x86_64-gobject-introspection to msyspac.txt

* Attempt to install p7zip in CI too

* Try removing base-devel

* Rename jobs to use 7Z

* Add missing space in error log

* Type up some thigns in Tauon class

* fix up pyproject.toml comment so I can sleep at night

* Mutagen ID3 does not support context managers, also log exception properly

* I suppose context manager does not belong here at all

* phazor: Use while(true) not while(1)

* Try fixing Windows close race condition

* Revert last commit

* phazor: Use pathlib

* Phazor: More explicit logging

* Try fixing cache delete fail

* Make cache check Windows only

* Fix up GuitarChords a fair bit

* Modularize Prefs

* Linux: Pack libcanberra-gtk-module.so

* Pack libcanberra-gtk3-module

* Fix Rsvg deprecation

* [svg|asset|scaled_asset]_directory to Path

* De-global LoadImageAsset, WhiteModImageAsset and asset_loader()

* Mark python-magic as optional

* Fix minimode crashing when song isn't playing

* Comment out python-magic installs

* Fix radio resource leak

* Fix radio playback

* Fix mini mode harder

* Undo unnecessary overfixing

* Remove libwayland*.so files from Linux CI builds and try fixing nested directories again

* Fix archive path for CI

* Fix Windows CI nesting too

* Comment out unused nonexistent Jellyfin thumbnail path

* Small typing additions and an error todo

* StarStore typing

* Fix imageasset __init__

* Jellyfin: Fix getting albumart for singles

* Fix crash trying to copy an empty playing_object() to clipboard

* Note fixed jellyfin cover integration in changelog

* Use user_directory from __main__ instead of duping it, and jump out of src in cloned installs

* Remove the dir change changelog as old behavior was restored

* Remove the necessity for asset_loader to be named and remove obvious params from the dirs

* Remove the rest of named params from asset_loader()

* I dont get how I missed these
  • Loading branch information
C0rn3j authored Jan 2, 2025
1 parent c2420e2 commit 60d2a75
Show file tree
Hide file tree
Showing 28 changed files with 1,989 additions and 1,721 deletions.
21 changes: 13 additions & 8 deletions .github/workflows/build_Linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
gobject-introspection \
gir1.2-rsvg-2.0 \
kde-config-gtk-style \
libcanberra-gtk3-module \
libgirepository1.0-dev \
python3-gi-cairo \
libayatana-appindicator3-dev \
Expand All @@ -41,7 +42,8 @@ jobs:
libsamplerate0-dev \
libsdl2-image-dev \
libvorbis-dev \
libwavpack-dev
libwavpack-dev \
p7zip
# JPEG-XL hack since 24.04 is too old
sudo apt-get install -y \
libgif7 \
Expand Down Expand Up @@ -82,17 +84,20 @@ jobs:
source .venv/bin/activate
pyinstaller --log-level=DEBUG linux.spec
- name: Create ZIP
- name: Remove libwayland*.so files due to https://github.com/pyinstaller/pyinstaller/issues/8963
run: rm ./dist/TauonMusicBox/_internal/libwayland*

- name: Create 7Z
run: |
mkdir -p dist/zip
APP_NAME="TauonMusicBox"
APP_PATH="dist/${APP_NAME}"
ZIP_PATH="dist/zip/${APP_NAME}.zip"
cd "dist/${APP_NAME}"
ARCHIVE_PATH="../../${APP_NAME}.7z"
zip -r "${ZIP_PATH}" "${APP_PATH}"
7z a -r "${ARCHIVE_PATH}" "."
- name: Upload ZIP artifact
- name: Upload 7Z artifact
uses: actions/upload-artifact@v4
with:
name: TauonMusicBox-linux
path: dist/zip/TauonMusicBox.zip
path: TauonMusicBox.7z
77 changes: 40 additions & 37 deletions .github/workflows/build_Windows_MINGW64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,24 @@ jobs:
with:
submodules: true

# TODO(Martin): This is duped from the file in extra, install from said file somehow instead
# TODO(Martin): p7zip should be 7zip but MINGW64 hasn't updated at the time of writing, try switching it later
- name: Read Package List
id: read_packages
run: |
$packages = Get-Content extra/msyspac.txt -Raw | Out-String
$packages = $packages -replace "`r`n", " " -replace "`n", " "
$packages = $packages.Trim() + " p7zip"
echo "packages=$packages" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8
- name: Set up MSYS2 MinGW-W64
uses: msys2/setup-msys2@v2
with:
msystem: mingw64
update: true
install: >-
base-devel
ca-certificates
cmake
ninja
zip
mingw-w64-x86_64-flac
mingw-w64-x86_64-gcc
mingw-w64-x86_64-gobject-introspection
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-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-python-zeroconf
mingw-w64-x86_64-rust
mingw-w64-x86_64-SDL2
mingw-w64-x86_64-SDL2_image
mingw-w64-x86_64-wavpack
mingw-w64-x86_64-zlib
install: ${{ env.packages }}
# ca-certificates
# mingw-w64-x86_64-python-zeroconf
# mingw-w64-x86_64-zlib

- name: Update CA trust and hack opusfile
shell: msys2 {0}
Expand All @@ -55,11 +41,11 @@ jobs:
- name: Install Python dependencies and setup venv
shell: msys2 {0}
run: |
python -m pip install --upgrade pip
python -m pip install --break-system-packages --upgrade pip
python -m venv .venv
source .venv/bin/activate
export CFLAGS="-I/mingw64/include"
pip install \
export PIP_FIND_LINKS=https://github.com/ddelange/python-magic/releases/expanded_assets/0.4.28.post8
.venv/bin/python -m pip install \
-r requirements.txt \
build \
pyinstaller
Expand All @@ -77,6 +63,23 @@ jobs:
source .venv/bin/activate
pip install --prefix ".venv" dist/*.whl
# https://github.com/Taiko2k/Tauon/pull/931#issuecomment-1464880133
- name: Download optionals from latest release files and notofonts' GitHub
shell: msys2 {0}
run: |
curl -L -o librespot.exe https://github.com/Taiko2k/Tauon/releases/download/v7.8.3/librespot.exe
curl -L -o TaskbarLib.tlb https://github.com/Taiko2k/Tauon/releases/download/v7.8.3/TaskbarLib.tlb
curl -L -o TauonSMTC.dll https://github.com/Taiko2k/Tauon/releases/download/v7.8.3/TauonSMTC.dll
mkdir fonts
curl -L -o fonts/NotoSans-ExtraCondensed.ttf https://github.com/notofonts/notofonts.github.io/raw/refs/heads/main/fonts/NotoSans/full/ttf/NotoSans-ExtraCondensed.ttf # 800KB
curl -L -o fonts/NotoSans-ExtraCondensedBold.ttf https://github.com/notofonts/notofonts.github.io/raw/refs/heads/main/fonts/NotoSans/full/ttf/NotoSans-ExtraCondensedBold.ttf # 800KB
curl -L -o fonts/NotoSans-Bold.ttf https://github.com/notofonts/notofonts.github.io/raw/refs/heads/main/fonts/NotoSans/full/ttf/NotoSans-Bold.ttf # 800KB
curl -L -o fonts/NotoSans-Medium.ttf https://github.com/notofonts/notofonts.github.io/raw/refs/heads/main/fonts/NotoSans/full/ttf/NotoSans-Medium.ttf # 800KB
curl -L -o fonts/NotoSans-Regular.ttf https://github.com/notofonts/notofonts.github.io/raw/refs/heads/main/fonts/NotoSans/full/ttf/NotoSans-Regular.ttf # 800KB
curl -L -o fonts/NotoSansCJKjp-Bold.otf https://github.com/notofonts/noto-cjk/raw/refs/heads/main/Sans/OTF/Japanese/NotoSansCJKjp-Bold.otf # 16MB
curl -L -o fonts/NotoSansCJKjp-Medium.otf https://github.com/notofonts/noto-cjk/raw/refs/heads/main/Sans/OTF/Japanese/NotoSansCJKjp-Medium.otf # 16MB
curl -L -o fonts/NotoSansCJKjp-Regular.otf https://github.com/notofonts/noto-cjk/raw/refs/heads/main/Sans/OTF/Japanese/NotoSansCJKjp-Regular.otf # 16MB
- name: "[DEBUG] List all files"
shell: msys2 {0}
run: find .
Expand All @@ -87,18 +90,18 @@ jobs:
source .venv/bin/activate
pyinstaller --log-level=DEBUG windows.spec
- name: Create ZIP
- name: Create 7Z
shell: msys2 {0}
run: |
mkdir -p dist/zip
APP_NAME="TauonMusicBox"
APP_PATH="dist/${APP_NAME}"
ZIP_PATH="dist/zip/${APP_NAME}.zip"
cd "dist/${APP_NAME}"
ARCHIVE_PATH="../../${APP_NAME}.7z"
zip -r "${ZIP_PATH}" "${APP_PATH}"
7z a -r "${ARCHIVE_PATH}" "."
- name: Upload ZIP artifact
- name: Upload 7Z artifact
uses: actions/upload-artifact@v4
with:
name: TauonMusicBox-windows
path: dist/zip/TauonMusicBox.zip
path: TauonMusicBox.7z
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ fonts/
*.mp3
build/
*.bat
*.idl
*.tlb
*.mo
prime/
Expand All @@ -32,4 +31,4 @@ dist/
src/tauon_music_box.egg-info
kissfft.tar.gz
miniaudio.tar.gz
debug
debug
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ Changelog

- **Added** TIDAL support
- **Added** Linux/macOS/Windows CI builds, restoring Windows and macOS build support
- **Changed** portable installations now save `cache` and `user-data` directiories in `src/tauon/`, move existing directories there if necessary
- **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 @@ -15,7 +14,8 @@ Changelog
- **Fixed** mishandling display change event, this fixes the "Grr" errors in the log
- **Fixed** loading configuration with negative integers, this fixes setting a negative baseline offset
- **Fixed** playlist being able to skip to next song even when current song was looped due to a race condition
- **Fixed** leaking file handlers when handling themes and databases, this may fix potential memory leaks
- **Fixed** leaking Resource handlers, this may fix potential memory leaks
- **Improved** Jellyfin integration - cover art now loads even for albumless tracks
- **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)
Expand Down
136 changes: 136 additions & 0 deletions extra/TaskbarLib.idl
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
// Used to create TaskbarLib.tlb through MIDL and Tlbimp.exe

// Compile in cmd.exe:
// set PATH=%PATH%;C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um
// "C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\x64\midl.exe" /I "C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um" /I "C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared" TaskbarLib.idl

// Source: https://www.neowin.net/forum/topic/716968-using-apis-in-a-objectaction-format/#comment-590434472
[
uuid(683BF642-E9CA-4124-BE43-67065B2FA653),
version(1.0),
]
library TaskbarLib
{
[
uuid(56FDF342-FD6D-11d0-958A-006097C9A090),
object,
]
interface ITaskbarList : IUnknown
{
HRESULT _stdcall HrInit();
HRESULT _stdcall AddTab([in] long hwnd);
HRESULT _stdcall DeleteTab([in] long hwnd);
HRESULT _stdcall ActivateTab([in] long hwnd);
HRESULT _stdcall SetActivateAlt([in] long hwnd);
};

[
uuid(602D4995-B13A-429b-A66E-1935E44F4317),
object,
]
interface ITaskbarList2 : ITaskbarList
{
HRESULT MarkFullscreenWindow(
[in] long hwnd,
[in] BOOL fFullscreen);
}

cpp_quote("#ifdef MIDL_PASS")
typedef IUnknown* HIMAGELIST;
typedef IUNknown* HICON;
cpp_quote("#endif")

cpp_quote("#include <pshpack8.h>")
typedef struct tagTHUMBBUTTON
{
DWORD dwMask;
UINT iId;
UINT iBitmap;
HICON hIcon;
WCHAR szTip[260];
DWORD dwFlags;
} THUMBBUTTON, *LPTHUMBBUTTON;
cpp_quote("#include <poppack.h>")

[
uuid(ea1afb91-9e28-4b86-90e9-9e9f8a5eefaf),
object,
]
interface ITaskbarList3 : ITaskbarList2
{
// Flags for Setting Taskbar Progress state
typedef [v1_enum] enum TBPFLAG
{
TBPF_NOPROGRESS = 0x00000000,
TBPF_INDETERMINATE = 0x00000001,
TBPF_NORMAL = 0x00000002,
TBPF_ERROR = 0x00000004,
TBPF_PAUSED = 0x00000008,
} TBPFLAG;

cpp_quote("DEFINE_ENUM_FLAG_OPERATORS(TBPFLAG)")

// Flags for SetTabActive
typedef [v1_enum] enum TBATFLAG
{
TBATF_USEMDITHUMBNAIL = 0x00000001,
TBATF_USEMDILIVEPREVIEW = 0x00000002,
} TBATFLAG;

cpp_quote("DEFINE_ENUM_FLAG_OPERATORS(TBATFLAG)")

HRESULT SetProgressValue(
[in] long hwnd,
[in] ULONGLONG ullCompleted,
[in] ULONGLONG ullTotal);

HRESULT SetProgressState(
[in] long hwnd,
[in] TBPFLAG tbpFlags);

HRESULT RegisterTab(
[in] long hwndTab,
[in] HWND hwndMDI);

HRESULT UnregisterTab(
[in] long hwndTab);

HRESULT SetTabOrder(
[in] long hwndTab,
[in] long hwndInsertBefore);

HRESULT SetTabActive(
[in] long hwndTab,
[in] long hwndMDI,
[in] TBATFLAG tbatFlags);

HRESULT ThumbBarAddButtons(
[in] long hwnd,
[in] UINT cButtons,
[in, size_is(cButtons)] LPTHUMBBUTTON pButton);

HRESULT ThumbBarUpdateButtons(
[in] long hwnd,
[in] UINT cButtons,
[in, size_is(cButtons)] LPTHUMBBUTTON pButton);

HRESULT ThumbBarSetImageList(
[in] long hwnd,
[in] HIMAGELIST himl);

HRESULT SetOverlayIcon(
[in] long hwnd,
[in] HICON hIcon,
[in, string] LPCWSTR pszDescription);

HRESULT SetThumbnailTooltip(
[in] long hwnd,
[in, string] LPCWSTR pszTip);

HRESULT SetThumbnailClip(
[in] long hwnd,
[in] RECT *prcClip);
}

[ uuid(56FDF344-FD6D-11d0-958A-006097C9A090) ] coclass TaskbarList { interface ITaskbarList3; }
};
3 changes: 3 additions & 0 deletions extra/msyspac.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
cmake
ninja
mingw-w64-x86_64-flac
mingw-w64-x86_64-gcc
mingw-w64-x86_64-gobject-introspection
mingw-w64-x86_64-gtk3
mingw-w64-x86_64-libgme
mingw-w64-x86_64-libopenmpt
Expand Down
3 changes: 2 additions & 1 deletion extra/requirements_optional.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
colored_traceback
colored_traceback; sys_platform != 'win32' # Disabled for Windows due to https://github.com/staticshock/colored-traceback.py/issues/25
jxlpy
#librespot - https://github.com/kokarare1212/librespot-python/pull/286
natsort
Expand All @@ -7,6 +7,7 @@ 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
#python-magic # WIP
pypresence
setproctitle
tekore
Expand Down
12 changes: 9 additions & 3 deletions linux.spec
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import sys

import certifi

python_ver = f"{sys.version_info.major}.{sys.version_info.minor}"

a = Analysis(
["src/tauon/__main__.py"],
pathex=[],
Expand All @@ -8,14 +12,16 @@ a = Analysis(
(certifi.where(), "certifi"),
("/usr/lib/x86_64-linux-gnu/gtk-3.0/modules/libcolorreload-gtk-module.so", "lib/gtk-3.0/modules"),
("/usr/lib/x86_64-linux-gnu/gtk-3.0/modules/libwindow-decorations-gtk-module.so", "lib/gtk-3.0/modules"),
("/usr/lib/x86_64-linux-gnu/gtk-3.0/modules/libcanberra-gtk-module.so", "lib/gtk-3.0/modules"),
("/usr/lib/x86_64-linux-gnu/gtk-3.0/modules/libcanberra-gtk3-module.so", "lib/gtk-3.0/modules"),
("src/tauon/assets", "assets"),
("src/tauon/locale", "locale"),
("src/tauon/theme", "theme"),
("src/tauon/templates", "templates"),
# This could only have SDL2.framework and SDL2_image.framework to save space...
(".venv/lib/python3.13/site-packages/sdl2dll/dll", "sdl2dll/dll"),
# (".venv/lib/python3.13/site-packages/sdl2dll/dll/SDL2.framework", "sdl2dll/dll/SDL2.framework"),
# (".venv/lib/python3.13/site-packages/sdl2dll/dll/SDL2_image.framework", "sdl2dll/dll/SDL2_image.framework"),
(f".venv/lib/python{python_ver}/site-packages/sdl2dll/dll", "sdl2dll/dll"),
# (f".venv/lib/python{python_ver}/site-packages/sdl2dll/dll/SDL2.framework", "sdl2dll/dll/SDL2.framework"),
# (f".venv/lib/python{python_ver}/site-packages/sdl2dll/dll/SDL2_image.framework", "sdl2dll/dll/SDL2_image.framework"),
],
hiddenimports=[
"pylast",
Expand Down
Loading

0 comments on commit 60d2a75

Please sign in to comment.