-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pyproject: Use pyproject.toml for building wheels
- Loading branch information
1 parent
532765c
commit c8b2cc7
Showing
8 changed files
with
108 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
include LICENSE | ||
include *.rst | ||
include doc/requirements.txt | ||
include sounddevice_build.py | ||
recursive-include _custom_build *.py | ||
include sounddevice.py | ||
recursive-include doc *.rst *.py | ||
recursive-include examples *.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.5.0 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
"""A Thin backend wrapper for setuptools.build_meta | ||
See https://setuptools.pypa.io/en/latest/build_meta.html | ||
""" | ||
|
||
from setuptools import build_meta as _orig | ||
from setuptools.build_meta import * | ||
import sounddevice_build | ||
import os | ||
import platform | ||
import shutil | ||
|
||
sounddevice_build.main() | ||
|
||
DARWIN = "Darwin" | ||
WINDOWS = "Windows" | ||
MACOSX_VERSIONS = ["maccosx_10_6_x86_64", "macosx_10_6_universal2"] | ||
|
||
|
||
def get_platform_specific_wheel_name() -> str: | ||
"""Return the platform specific wheel name.""" | ||
current_platform = os.environ.get("PYTHON_SOUNDDEVICE_PLATFORM", platform.system()) | ||
architecture = os.environ.get("PYTHON_SOUNDDEVICE_ARCHITECTURE", platform.architecture()[0]) | ||
oses = "any" | ||
|
||
if current_platform == DARWIN: | ||
oses = ".".join(MACOSX_VERSIONS) | ||
elif current_platform == WINDOWS: | ||
oses = "win32" if architecture == "32bit" else "win_amd64" | ||
|
||
with open("VERSION", "r") as f: | ||
version = f.read().strip() | ||
|
||
return f"sounddevice-{version}-py3-none-{oses}.whl" | ||
|
||
|
||
def prepare_meta_for_build_wheel(config_settings=None): | ||
"""This function may be used in the future to customize platform specific portaudio libraries.""" | ||
return _orig.prepare_metadata_for_build_wheel(config_settings=config_settings) | ||
|
||
|
||
def get_requires_for_build_wheel(config_settings=None): | ||
return _orig.get_requires_for_build_wheel(config_settings=config_settings) | ||
|
||
|
||
def build_wheel(wheel_directory, config_settings=None, metadata_directory=None): | ||
"""Intercept the build wheel function and copy the wheel to a platform specific name. | ||
We build the wheel as ususal for the package but intercept the output so that we can rename it. | ||
""" | ||
|
||
wheel_file = _orig.build_wheel(wheel_directory, config_settings=config_settings, metadata_directory=metadata_directory) | ||
old_wheel_path = os.path.join(wheel_directory, wheel_file) | ||
new_wheel_path = os.path.join(wheel_directory, get_platform_specific_wheel_name()) | ||
|
||
shutil.move(old_wheel_path, new_wheel_path) | ||
|
||
return new_wheel_path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,41 @@ | ||
[build-system] | ||
requires = ["setuptools >= 61.0"] | ||
build-backend = "setuptools.build_meta" | ||
requires = ["setuptools", "wheel", "CFFI>=1.0.0"] | ||
build-backend = "backend" | ||
backend-path = ["_custom_build"] | ||
|
||
[project] | ||
name = "sounddevice" | ||
description = "Play and Record Sound with Python" | ||
requires-python = ">=3.7" | ||
readme = "README.rst" | ||
license = { file = "LICENSE" } | ||
keywords = ["sound", "audio", "play", "record", "playrec", "PortAudio"] | ||
authors = [{ name = "Matthias Geier", email = "[email protected]" }] | ||
classifiers = [ | ||
"License :: OSI Approved :: MIT License", | ||
"Operating System :: OS Independent", | ||
"Programming Language :: Python", | ||
"Programming Language :: Python :: 3", | ||
"Topic :: Multimedia :: Sound/Audio" | ||
] | ||
urls = { "Source" = "https://github.com/spatialaudio/python-sounddevice" } | ||
dependencies = ["CFFI>=1.0.0"] | ||
dynamic = ["version"] | ||
|
||
[project.optional-dependencies] | ||
NumPy = ["NumPy"] | ||
|
||
[tool.setuptools] | ||
zip-safe = false | ||
py-modules = ["sounddevice", "_sounddevice"] | ||
packages = ["_sounddevice_data"] | ||
|
||
[tool.setuptools.package-data] | ||
"_sounddevice_data"= [ | ||
"portaudio-binaries/*.dll", | ||
"portaudio-binaries/*.dylib", | ||
"portaudio-binaries/*.md" | ||
] | ||
|
||
[tool.setuptools.dynamic] | ||
version = { "file" = "VERSION" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters