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

chore: package updates #239

Merged
merged 3 commits into from
Nov 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/install-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ make install
ls -laR portaudio-install
cd ..

pip3 install -U pyinstaller==4.10
pip3 install -U pyinstaller==5.6.2

pyinstaller friture.spec -y --log-level=DEBUG

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/install-macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ python3 setup.py build_ext --inplace
# see: https://github.com/tlecomte/friture/issues/154
brew install portaudio --HEAD

pip3 install -U pyinstaller==4.10
pip3 install -U pyinstaller==5.6.2

pyinstaller friture.spec -y --onedir --windowed
pyinstaller friture.spec -y

ls -la dist/*

Expand Down
59 changes: 48 additions & 11 deletions installer/pyinstaller-hooks/hook-sounddevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,66 @@
#
# SPDX-License-Identifier: GPL-2.0-or-later
# ------------------------------------------------------------------
# -----------------------------------------------------------------------------

"""
sounddevice:
https://github.com/spatialaudio/python-sounddevice/
"""

import os
import pathlib

from PyInstaller.compat import is_darwin, is_win
from PyInstaller.utils.hooks import get_package_paths
from PyInstaller.compat import is_darwin
from PyInstaller.utils.hooks import get_module_file_attribute, logger

sfp = get_package_paths("sounddevice")
binaries = []
datas = []

path = None
if is_win:
path = os.path.join(sfp[0], "_sounddevice_data", "portaudio-binaries")
elif is_darwin:
# PyPI wheels for Windows and macOS ship the sndfile shared library in _sounddevice_data directory,
# located next to the sounddevice.py module file (i.e., in the site-packages directory).
module_dir = pathlib.Path(get_module_file_attribute('sounddevice')).parent
data_dir = module_dir / '_sounddevice_data' / 'portaudio-binaries'

if is_darwin:
# for Macos Big Sur, the stable portaudio (19.6.0) makes Friture freeze on startup
# so we build our own and bundle it manually here
path = "/usr/local/lib/libportaudio.dylib"
destdir = str(data_dir.relative_to(module_dir))
binaries += [(path, destdir)]
if not os.path.isfile(path):
raise ValueError('libportaudio could not be found')
elif data_dir.is_dir():
destdir = str(data_dir.relative_to(module_dir))

# Collect the shared library (known variants: libportaudio64bit.dll, libportaudio32bit.dll, libportaudio.dylib)
for lib_file in data_dir.glob("libportaudio*.*"):
binaries += [(str(lib_file), destdir)]

# Collect the README.md file
readme_file = data_dir / "README.md"
if readme_file.is_file():
datas += [(str(readme_file), destdir)]
else:
# On linux and in Anaconda in all OSes, the system-installed portaudio library needs to be collected.
def _find_system_portaudio_library():
import os
import ctypes.util
from PyInstaller.depend.utils import _resolveCtypesImports

libname = ctypes.util.find_library("portaudio")
if libname is not None:
resolved_binary = _resolveCtypesImports([os.path.basename(libname)])
if resolved_binary:
return resolved_binary[0][1]

try:
lib_file = _find_system_portaudio_library()
except Exception as e:
logger.warning("Error while trying to find system-installed portaudio library: %s", e)
lib_file = None

if lib_file:
binaries += [(lib_file, '.')]

if path is not None and os.path.exists(path):
binaries = [(path,
os.path.join("_sounddevice_data", "portaudio-binaries"))]
if not binaries:
logger.warning("portaudio shared library not found - sounddevice will likely fail to work!")
12 changes: 6 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,17 @@ def include_dirs(self, dirs):
# these will be installed when calling 'pip install friture'
# they are also retrieved by 'requirements.txt'
install_requires = [
"sounddevice==0.4.2",
"rtmixer==0.1.3",
"docutils==0.17.1",
"numpy==1.22.1",
"PyQt5==5.15.4",
"sounddevice==0.4.5",
"rtmixer==0.1.4",
"docutils==0.19",
"numpy==1.23.4",
"PyQt5==5.15.7",
"appdirs==1.4.4",
"pyrr==0.10.3",
]

# Cython and numpy are needed when running setup.py, to build extensions
setup_requires=["numpy==1.22.1", "Cython==0.29.24"]
setup_requires=["numpy==1.23.4", "Cython==0.29.32"]

with open(join(dirname(__file__), 'README.rst')) as f:
long_description = f.read()
Expand Down
2 changes: 1 addition & 1 deletion winbuild.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Write-Host "==========================================="
Write-Host "Installing pyinstaller"
Write-Host "==========================================="

& pip install -U pyinstaller==4.10
& pip install -U pyinstaller==5.6.2

Write-Host ""
Write-Host "==========================================="
Expand Down