Skip to content

Commit

Permalink
Enable Nuitka builds on M1 Mac
Browse files Browse the repository at this point in the history
Nuitka crashes on my Catalina Intel Mac, and I doubt that it will
ever get fixed.  So continue using Pyinstaller
  • Loading branch information
stargateaudio committed Nov 1, 2023
1 parent 6f5ea18 commit 42caa97
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 10 deletions.
27 changes: 26 additions & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,32 @@ nuitka-appimage:
scripts/stargate

nuitka-appbundle:
exit 1
python3 -m nuitka \
--standalone \
--include-module=sgui \
--include-module=sglib \
--include-qt-plugins=platform,sensible \
--enable-plugin=pyqt6 \
--include-data-dir=files=files \
--include-data-files=engine/stargate-engine=engine/ \
--include-data-files=engine/*.dylib=engine/ \
--include-data-files=engine/sbsms=engine/ \
--include-data-files=meta.json=meta.json \
--include-data-files=COMMIT=COMMIT \
--include-data-files=engine/sbsms=engine/ \
--include-data-files=engine/rubberband=engine/ \
--include-data-files=engine/stargate-soundstretch=engine/ \
--macos-target-arch=arm64 \
--macos-create-app-bundle \
--macos-app-icon=macos/stargate.icns \
--macos-app-name='Stargate DAW' \
--macos-signed-app-name=com.github.stargatedaw.stargate \
--macos-app-mode=gui \
--macos-app-version=$(MINOR) \
scripts/stargate
mkdir -p dist
rm -rf dist/stargate.app/
mv stargate.app 'dist/Stargate DAW.app'

py_vendor:
# Vendor Python dependencies not commonly available in distro repos
Expand Down
18 changes: 13 additions & 5 deletions src/macos/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,19 @@ def parse_args():
if os.path.isdir(BUNDLE_PATH):
shutil.rmtree(BUNDLE_PATH)

retcode = subprocess.check_call([
'pyinstaller',
'--noconfirm',
'pyinstaller-mac-onedir.spec',
])
if ARCH == 'x86_64':
retcode = subprocess.check_call([
'pyinstaller',
'--noconfirm',
'pyinstaller-mac-onedir.spec',
])
elif ARCH == 'arm64':
retcode = subprocess.check_call([
'make',
'nuitka-appbundle',
])
else:
assert False, f"Unknown arch. {ARCH}"
assert retcode == 0, retcode

os.chdir('dist')
Expand Down
2 changes: 2 additions & 0 deletions src/macos/requirements-m1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
PyQt6==6.5.0
PyQt6-Qt6==6.5.1

Nuitka

jinja2
mido
mutagen
Expand Down
28 changes: 24 additions & 4 deletions src/sg_py_vendor/wavefile/libsndfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
else:
dllName = 'libsndfile'

print(sys.platform)
print(dllName)

_lib=None
try:
from ctypes.util import find_library
Expand All @@ -51,14 +54,31 @@
dllPath = dllName
print(dllPath)
_lib = ct.CDLL(dllPath)
except:
except Exception as ex:
print(f'Could not load {dllPath}: {ex}')

if not _lib:
try:
#if not, get the dll installed with the wrapper
import os
dllPath = os.path.dirname(os.path.abspath(__file__))
_lib = ct.CDLL(os.path.join(dllPath, dllName))
except:
raise Exception("could not import libsndfile dll, make sure the dll '%s' is in the path"%(dllName))
except Exception as ex:
print(f'Could not load {dllPath}: {ex}')

if not _lib:
try:
dllPath = os.path.dirname(os.path.abspath(sys.executable))
dllPath = os.path.join(dllPath, 'engine', dllName)
print(dllPath)
_lib = ct.CDLL(dllPath)
except Exception as ex:
print(f'Could not load {dllPath}: {ex}')

if not _lib:
raise Exception(
f"could not import libsndfile dll, make sure the dll '{dllName}' "
"is in the path"
)

_lib.sf_version_string.restype = ct.c_char_p
_lib.sf_version_string.argtypes = None
Expand Down

0 comments on commit 42caa97

Please sign in to comment.