Can't get app to build
code-monki opened this issue · comments
System Config
2020 M1 Mac Mini
16GB RAM
Python 3.11.7
Problem Description
Cannot build app from repo
Steps to recreate
- Clone app from repo
- Install dependencies (wxpython PyInstaller simpleaudio requests)
- Change to cardstock directory
- python designer.py
Error Log
Traceback (most recent call last):
File "/Users/chuck/fiddle/code/CardStock/cardstock/designer.py", line 27, in <module>
from viewer import ViewerFrame
File "/Users/chuck/fiddle/code/CardStock/cardstock/viewer.py", line 27, in <module>
from runner import Runner
File "/Users/chuck/fiddle/code/CardStock/cardstock/runner.py", line 28, in <module>
from streamp3 import MP3Decoder
ModuleNotFoundError: No module named 'streamp3'
When attempting to install streamp3:
pip install streamp3 2>build.log
Collecting streamp3
Using cached streamp3-0.1.12.tar.gz (10 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Installing backend dependencies ... done
Preparing metadata (pyproject.toml) ... done
Collecting Cython==0.29.34 (from streamp3)
Using cached Cython-0.29.34-py2.py3-none-any.whl (988 kB)
Building wheels for collected packages: streamp3
Building wheel for streamp3 (pyproject.toml) ... error
Failed to build streamp3
Error Log
error: subprocess-exited-with-error
× Building wheel for streamp3 (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [7 lines of output]
/private/var/folders/46/js_q6q9n6555jsbl_23gzx7w0000gn/T/pip-build-env-v1ij8rns/overlay/lib/python3.11/site-packages/Cython/Compiler/Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: /private/var/folders/46/js_q6q9n6555jsbl_23gzx7w0000gn/T/pip-install-8nnx7fp8/streamp3_cda0fbf45c564c8591a36ffe6136cdbf/lame/hip.pyx
tree = Parsing.p_module(s, pxd, full_module_name)
lame/hip.c:750:10: fatal error: 'lame/lame.h' file not found
#include <lame/lame.h>
^~~~~~~~~~~~~
1 error generated.
error: command '/usr/bin/clang' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for streamp3
ERROR: Could not build wheels for streamp3, which is required to install pyproject.toml-based projects
Thanks for catching this. I added mp3 playback support recently, but installing streamp3 and its dependency lame is not always straightforward. I'll make mp3 support optional, and update the requirements.txt and install instructions.
I made CardStock's mp3 support optional now, so running without lame and steamp3 installed should work. To get streamp3 to install, you'll need to first install the non-python lame library/tool.
sudo apt install lame # Linux
brew install lame # MacOS
I added the following;
export CPPFLAGS=-I/opt/homebrew/include
export LDFLAGS=-L/opt/homebrew/lib
pip install streamp3
[NOTE: On an M1 Mac, Homebrew installs to /opt/homebrew and dumps the include and lib files in the /opt/homebrew directory.]
The library successfully built and installed.
I executed a git pull
to make sure I had the latest code changes and then changed to the cardstock directory in the repo and ran python build.py
.
No joy as PyInstaller throws the following error:
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/PyInstaller/building/utils.py", line 297, in process_collected_binary
raise SystemError(f"Failed to process binary {cached_name!r}!") from e
SystemError: Failed to process binary '/Users/chuck/Library/Application Support/pyinstaller/bincache00py31164bit/arm64/adhoc/no-entitlements/standalone.app/Contents/MacOS/standalone'!
It looks like I need to set up some sort of entitlement. I'll research that and see if I can find a solution.
UPDATE: Looks like the app needs an Info.plist file Setting entitlements on executables
@code-monki Does the latest release v0.99.5 work for you?
Looks like PyInstaller needs to have an entitlements.plist file with the following in it:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key><true/>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key><true/>
</dict>
</plist>
added for OS X with the --osx-entitlements-file
command line flag (or whatever the equivalent is when using the PyInstaller library.
Let me stand corrected. Just managed to build a "standalone" stack as an App. However, when I run python build.py, PyInstaller fails.
Did you downgrade PyInstaller to version 5.13.2? The 6.x code doesn't allow an app to be embedded inside of an app.
Closed as this is now working on v0.99.5. Please reopen if you continue to see problems!