Taiko2k / Tauon

The music player of today! :city_sunrise:
https://tauonmusicbox.rocks
GNU General Public License v3.0
1.81k stars 71 forks source link

macOS support (experimental) #577

Open Taiko2k opened 3 years ago

Taiko2k commented 3 years ago

Welcome to Tauon Music Box support for macOS.

Note that this is experimental and there are some caveats:

Caveats:

How to build and install:

The build instructions below will give you a .app so once done you can use it like a normal desktop app.

  1. Install Homebrew
  2. Install main dependencies brew install pygobject3 gtk+3 python ffmpeg pyinstaller libao sdl2 sdl2_image flac mpg123 opusfile libopenmpt libsamplerate libvorbis librsvg wavpack
  3. Clone Tauon repo git clone --recursive https://github.com/Taiko2k/TauonMusicBox.git
  4. cd TauonMusicBox
  5. Install python dependencies pip3 install -r requirements.txt
  6. Run bash compile-phazor.sh (some warnings in the output are ok, as long as there was no error)
  7. You can run using python3 tauon.py
  8. Build .app by running pyinstaller mac.spec --clean --noconfirm Package script currently broken, have to run from terminal.

That should give you a (hopefully working) .app in the TauonMusicBox/dist directory that you can run as is or move to your applications folder.

Note that the script currently has a limitation in that the built .app is still linked to the homebrew prefix, so removing or updating the prefix may cause the .app to stop working.

Note that user data is kept in ~/.local/share/TauonMusicBox

fangxx3863 commented 2 years ago

I succeeded
it also need to brew install librsvg and edit mac.spec modify hiddenimports=[], to hiddenimports=['sdl2', 'pylast'],

Taiko2k commented 2 years ago

I succeeded it also need to brew install librsvg and edit mac.spec modify hiddenimports=[], to hiddenimports=['sdl2', 'pylast'],

Neat. Ive now updated the instructions and script with the modifications you made.

fangxx3863 commented 2 years ago

I tried again with the new instructions, now on Monterey (12.1). Got through the build process without errors, other than pip reminding me about the deprecation of distutils. I tried to run the resulting TMB executable and got the following error:

[23812] Error loading Python lib '/Users/jkglenn/src/TauonMusicBox/build/mac/Python': dlopen: dlopen(/Users/jkglenn/src/TauonMusicBox/build/mac/Python, 0x000A): tried: '/Users/jkglenn/src/TauonMusicBox/build/mac/Python' (no such file), '/usr/local/lib/Python' (no such file), '/usr/lib/Python' (no such file)

I currently have a homebrew-installed Python which is symlinked to /usr/local/opt/python@3.9/libexec/bin/python.

I think you can try a virtual environment
Use anaconda or python venv
https://docs.python.org/3/library/venv.html
Also note that the python version cannot be 3.10.0
Because pyinstaller cannot run normally under version 3.10.0
https://github.com/pyinstaller/pyinstaller/issues/5693
In addition, the .app file generated by my build (BigSur 11.0) is in the dist directory
I wish you success (my English is not good, sorry)

a-hurst commented 2 years ago

todo: unlink app from homebrew prefix, it can break on homebrew update. (SDL2 libs causing the issue?)

@Taiko2k You might have better luck adding the pysdl2-dll Python package as a dependency for macOS, it contains the latest official signed SDL2 and Mixer binaries from libSDL.org in a Python wheel that PySDL2 can automatically find and use! It's the current recommended way to use PySDL2 on all major platforms, since installing the SDL2 binaries system-wide on Windows is a big pain and so many Linux distros bundle very out-of-date SDL/ttf/mixer/image versions.

Also, if you have any other questions/comments/complaints/feature requests for the PySDL2 project, please let me know! I'm the current maintainer and want to be sure I'm doing good outreach for projects that use it. 🙂

Taiko2k commented 2 years ago

@a-hurst Indeed I noticed pysdl2-dll, I was going to give it a try but I'm waiting on Apple Silicon support.

Thanks for working on PySDL2, its a great library and I haven't had any issues with it.

fyrefiend commented 2 years ago

I'd absolutely love a precompiled Tauon pkg, app, or cask for Mac.

I can run it fine if I start it from terminal with 'python3 tauon.py'. However, when following these directions I'm getting the same issue as @cschx

I'm running macOS 12.3.1 x86_64 If there is any info I can add please let me know and I'll happily supply it.

Taiko2k commented 2 years ago

@fyrefiend If you run the built app from terminal it might give us a more helpful error message which we could take a look at. From the project root try run:

"dist/TauonMusicBox.app/Contents/MacOS/Tauon Music Box"

fyrefiend commented 2 years ago

Gladly. Sorry, I should have done that to begin with.

Traceback (most recent call last): File "tauon.py", line 8, in <module> from sdl2 import * ModuleNotFoundError: No module named 'sdl2' [27344] Failed to execute script 'tauon' due to unhandled exception: No module named 'sdl2' [27344] Traceback: Traceback (most recent call last): File "tauon.py", line 8, in <module> from sdl2 import * ModuleNotFoundError: No module named 'sdl2'

However it is installed as 'python3 tauon.py' works fine

Taiko2k commented 2 years ago

Could try see if pysdl2-dll helps.

Try pip install pysdl2-dll, then hmm, might need to edit mac.spec file and add sdl2dll to the "hiddenimports" line.

fyrefiend commented 2 years ago

Thank you for the reply. I've installed pysld12-dkk and added it to the mac.spec file but still getting:

Traceback (most recent call last): File "tauon.py", line 8, in <module> from sdl2 import * ModuleNotFoundError: No module named 'sdl2' [32126] Failed to execute script 'tauon' due to unhandled exception: No module named 'sdl2' [32126] Traceback: Traceback (most recent call last): File "tauon.py", line 8, in <module> from sdl2 import * ModuleNotFoundError: No module named 'sdl2'

Attached in the warn-mac.txt that pyinstaller generated. It's saying sdl2 is not installed but if I can run the python file itself fine so it's obviously installed. warn-mac.txt

a-hurst commented 2 years ago

@fyrefiend Hi there, PySDL2 maintainer here: looks like you've installed pysdl2-dll (the package with the pre-compiled SDL2 binaries for your OS) but not pysdl2 itself (the Python bindings for SDL2 and its addon libraries). Try running pip install pysdl2 and try again!

Also note that the latest pysdl2-dll binaries aren't yet fully natively compatible with Apple Silicon: since pysdl2-dll just bundles the official code-signed libSDL binaries for Windows and macOS, I've been waiting patiently for the SDL people to release universal binaries of SDL2_image and SDL2_mixer so I can update pysdl2-dll accordingly. Luckily it looks like new releases of both are imminent, so you shouldn't have to wait long.

fyrefiend commented 2 years ago

@a-hurst Thank you for replying. When I ran that I got:

DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621 Requirement already satisfied: pysdl2 in /Users/fyre/Library/Python/3.9/lib/python/site-packages (0.9.11) DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621

I'm going to be completely honest, I'm not a programmer nor do I play one on TV so I'm grateful for y'all trying to help.

a-hurst commented 2 years ago

@fyrefiend I don't have much experience with PyInstaller, but did you put pysdl2 in your mac.spec file along with pysdl2-dll? It'll need both to be self-contained.

fyrefiend commented 2 years ago

@a-hurst Tried including both in mac.spec but still getting the same error. Thank you though

boromil commented 2 years ago

bash ./compile-phazor.sh

complains about missing wavpack pkg

brew install wavpack

fixes that, but then I get:

clang: error: no such file or directory: 'src/phazor/kissfft/kiss_fftr.c' clang: error: no such file or directory: 'src/phazor/kissfft/kiss_fft.c'

removing references to these (bad idea, I know) from the build script, produces another error:

src/phazor/phazor.c:41:10: fatal error: 'miniaudio/miniaudio.h' file not found

dl the header file and placing it in src/phazor

mkdir src/phazor/miniaudio cd src/phazor/miniaudio curl -O https://raw.githubusercontent.com/mackron/miniaudio/master/miniaudio.h

results in:

... /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreAudio.framework/Headers/AudioHardwareBase.h:208:5: note: 'kAudioObjectPropertyElementMaster' has been explicitly marked deprecated here kAudioObjectPropertyElementMaster API_DEPRECATED_WITH_REPLACEMENT("kAudioObjectPropertyElementMain", macos(10.0, 12.0), ios(2.0, 15.0), watchos(1.0, 8.0), tvos(9.0, 15.0)) = kAudioObjectPropertyElementMain ^ src/phazor/phazor.c:52:10: fatal error: 'kissfft/kiss_fftr.h' file not found

include "kissfft/kiss_fftr.h"

So the build process seems broken for now ;/

Taiko2k commented 2 years ago

@boromil yeah the instructions were a little out of date. Ive updated them now, note the change to step 3.

Though the built package is currently crashing it seems, so this all might not be very useful.

denppa commented 2 years ago

M1 Mac Mini Mac OS Montery 12.5

Ran the bash command but 14 warnings and 4 errors occurred:

/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreAudio.framework/Headers/AudioHardwareBase.h:208:5: note: 'kAudioObjectPropertyElementMaster' has been explicitly marked deprecated here
    kAudioObjectPropertyElementMaster API_DEPRECATED_WITH_REPLACEMENT("kAudioObjectPropertyElementMain", macos(10.0, 12.0), ios(2.0, 15.0), watchos(1.0, 8.0), tvos(9.0, 15.0)) = kAudioObjectPropertyElementMain
    ^
src/phazor/phazor.c:1671:9: error: implicit declaration of function 'stop_out' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        stop_out();
        ^
src/phazor/phazor.c:1811:48: error: implicit declaration of function 'start_out' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    if (reconnect == 1 && sample_rate_src > 0) start_out();
                                               ^
src/phazor/phazor.c:1814:6: error: conflicting types for 'start_out'
void start_out(){
     ^
src/phazor/phazor.c:1811:48: note: previous implicit declaration is here
    if (reconnect == 1 && sample_rate_src > 0) start_out();
                                               ^
src/phazor/phazor.c:1823:6: error: conflicting types for 'stop_out'
void stop_out(){
     ^
src/phazor/phazor.c:1671:9: note: previous implicit declaration is here
        stop_out();
        ^
14 warnings and 4 errors generated.
Taiko2k commented 2 years ago

Ive committed a fix for the above compile issue now.

melvyn2 commented 2 years ago

Worked with a single typo in step 6: phazor not phasor Also the pyinstaller step does work, I get a standalone .app Thanks!

Looooopy commented 2 years ago

i'm getting these errors when i try to install it on a macos ...

src/phazor/phazor.c:1082:9: warning: unused variable 'b' [-Wunused-variable]
    int b = get_audio(frameCount * 2, pOutput);
        ^
src/phazor/phazor.c:1179:9: error: implicit declaration of function 'decode_seek' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        decode_seek(position_count / current_sample_rate * 1000, sample_rate_src);
        ^
src/phazor/phazor.c:1198:6: error: conflicting types for 'decode_seek'
void decode_seek(int abs_ms, int sample_rate) {
     ^
src/phazor/phazor.c:1179:9: note: previous implicit declaration is here
        decode_seek(position_count / current_sample_rate * 1000, sample_rate_src);

But my arch linux install is rocking hard :)

Looooopy commented 2 years ago

I inserted a predeclaration up on top on the file src/phazor/phazor.c and got it to work

inserted this at line 70 void decode_seek(int abs_ms, int sample_rate);

earnost commented 2 months ago

I feel like I'm so close. Worked out several issues but now stuck on this. When I run bash compile-phazor.sh I get:

Package libpipewire-0.3 was not found in the pkg-config search path. Perhaps you should add the directory containing `libpipewire-0.3.pc' to the PKG_CONFIG_PATH environment variable No package 'libpipewire-0.3' found src/phazor/phazor.c:69:10: fatal error: 'opusfile.h' file not found

include "opusfile.h"

     ^~~~~~~~~~~~

I'm on a 2019 Intel Macbook Pro. Searched the web but couldn't figure out how to get this libpipewire-0.3. Any help is appreciated as I'm fairly new at this. I think that's my last issue and then it should run. Thanks for your help.

Taiko2k commented 2 months ago

@earnost The script broke for non Linux platforms, I've committed a possible fix, try pull and try again.

earnost commented 2 months ago

Thank you, what's the possible fix? I don't see it

Taiko2k commented 2 months ago

https://github.com/Taiko2k/Tauon/commit/361eb16f92d3984d29726545ccd5b37fa6fcaca5