From f0513e3a460994c9e9a6c57fd385f7818ca0077a Mon Sep 17 00:00:00 2001 From: Otto Date: Sat, 8 Jun 2024 16:43:39 +0200 Subject: [PATCH 01/28] Start python bindings with maturin --- python/.github/workflows/CI.yml | 169 ++++++++++++++++++++++++++++++++ python/.gitignore | 72 ++++++++++++++ python/Cargo.toml | 12 +++ python/pyproject.toml | 15 +++ python/src/lib.rs | 14 +++ 5 files changed, 282 insertions(+) create mode 100644 python/.github/workflows/CI.yml create mode 100644 python/.gitignore create mode 100644 python/Cargo.toml create mode 100644 python/pyproject.toml create mode 100644 python/src/lib.rs diff --git a/python/.github/workflows/CI.yml b/python/.github/workflows/CI.yml new file mode 100644 index 00000000..8a87af1e --- /dev/null +++ b/python/.github/workflows/CI.yml @@ -0,0 +1,169 @@ +# This file is autogenerated by maturin v1.6.0 +# To update, run +# +# maturin generate-ci github +# +name: CI + +on: + push: + branches: + - main + - master + tags: + - '*' + pull_request: + workflow_dispatch: + +permissions: + contents: read + +jobs: + linux: + runs-on: ${{ matrix.platform.runner }} + strategy: + matrix: + platform: + - runner: ubuntu-latest + target: x86_64 + - runner: ubuntu-latest + target: x86 + - runner: ubuntu-latest + target: aarch64 + - runner: ubuntu-latest + target: armv7 + - runner: ubuntu-latest + target: s390x + - runner: ubuntu-latest + target: ppc64le + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: 3.x + - name: Build wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.platform.target }} + args: --release --out dist --find-interpreter + sccache: 'true' + manylinux: auto + - name: Upload wheels + uses: actions/upload-artifact@v4 + with: + name: wheels-linux-${{ matrix.platform.target }} + path: dist + + musllinux: + runs-on: ${{ matrix.platform.runner }} + strategy: + matrix: + platform: + - runner: ubuntu-latest + target: x86_64 + - runner: ubuntu-latest + target: x86 + - runner: ubuntu-latest + target: aarch64 + - runner: ubuntu-latest + target: armv7 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: 3.x + - name: Build wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.platform.target }} + args: --release --out dist --find-interpreter + sccache: 'true' + manylinux: musllinux_1_2 + - name: Upload wheels + uses: actions/upload-artifact@v4 + with: + name: wheels-musllinux-${{ matrix.platform.target }} + path: dist + + windows: + runs-on: ${{ matrix.platform.runner }} + strategy: + matrix: + platform: + - runner: windows-latest + target: x64 + - runner: windows-latest + target: x86 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: 3.x + architecture: ${{ matrix.platform.target }} + - name: Build wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.platform.target }} + args: --release --out dist --find-interpreter + sccache: 'true' + - name: Upload wheels + uses: actions/upload-artifact@v4 + with: + name: wheels-windows-${{ matrix.platform.target }} + path: dist + + macos: + runs-on: ${{ matrix.platform.runner }} + strategy: + matrix: + platform: + - runner: macos-12 + target: x86_64 + - runner: macos-14 + target: aarch64 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: 3.x + - name: Build wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.platform.target }} + args: --release --out dist --find-interpreter + sccache: 'true' + - name: Upload wheels + uses: actions/upload-artifact@v4 + with: + name: wheels-macos-${{ matrix.platform.target }} + path: dist + + sdist: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Build sdist + uses: PyO3/maturin-action@v1 + with: + command: sdist + args: --out dist + - name: Upload sdist + uses: actions/upload-artifact@v4 + with: + name: wheels-sdist + path: dist + + release: + name: Release + runs-on: ubuntu-latest + if: "startsWith(github.ref, 'refs/tags/')" + needs: [linux, musllinux, windows, macos, sdist] + steps: + - uses: actions/download-artifact@v4 + - name: Publish to PyPI + uses: PyO3/maturin-action@v1 + env: + MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }} + with: + command: upload + args: --non-interactive --skip-existing wheels-*/* diff --git a/python/.gitignore b/python/.gitignore new file mode 100644 index 00000000..c8f04429 --- /dev/null +++ b/python/.gitignore @@ -0,0 +1,72 @@ +/target + +# Byte-compiled / optimized / DLL files +__pycache__/ +.pytest_cache/ +*.py[cod] + +# C extensions +*.so + +# Distribution / packaging +.Python +.venv/ +env/ +bin/ +build/ +develop-eggs/ +dist/ +eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +include/ +man/ +venv/ +*.egg-info/ +.installed.cfg +*.egg + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt +pip-selfcheck.json + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.cache +nosetests.xml +coverage.xml + +# Translations +*.mo + +# Mr Developer +.mr.developer.cfg +.project +.pydevproject + +# Rope +.ropeproject + +# Django stuff: +*.log +*.pot + +.DS_Store + +# Sphinx documentation +docs/_build/ + +# PyCharm +.idea/ + +# VSCode +.vscode/ + +# Pyenv +.python-version diff --git a/python/Cargo.toml b/python/Cargo.toml new file mode 100644 index 00000000..ee680b31 --- /dev/null +++ b/python/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "web_audio_api" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[lib] +name = "web_audio_api" +crate-type = ["cdylib"] + +[dependencies] +pyo3 = "0.21.1" diff --git a/python/pyproject.toml b/python/pyproject.toml new file mode 100644 index 00000000..14ce3fc5 --- /dev/null +++ b/python/pyproject.toml @@ -0,0 +1,15 @@ +[build-system] +requires = ["maturin>=1.6,<2.0"] +build-backend = "maturin" + +[project] +name = "python" +requires-python = ">=3.8" +classifiers = [ + "Programming Language :: Rust", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", +] +dynamic = ["version"] +[tool.maturin] +features = ["pyo3/extension-module"] diff --git a/python/src/lib.rs b/python/src/lib.rs new file mode 100644 index 00000000..6a3f1061 --- /dev/null +++ b/python/src/lib.rs @@ -0,0 +1,14 @@ +use pyo3::prelude::*; + +/// Formats the sum of two numbers as string. +#[pyfunction] +fn sum_as_string(a: usize, b: usize) -> PyResult { + Ok((a + b).to_string()) +} + +/// A Python module implemented in Rust. +#[pymodule] +fn web_audio_api(m: &Bound<'_, PyModule>) -> PyResult<()> { + m.add_function(wrap_pyfunction!(sum_as_string, m)?)?; + Ok(()) +} From 7232a500894e1f8518c05bccbbb14eea3dd95cc1 Mon Sep 17 00:00:00 2001 From: Otto Date: Sat, 8 Jun 2024 16:56:34 +0200 Subject: [PATCH 02/28] ignore .env --- python/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/python/.gitignore b/python/.gitignore index c8f04429..c1813783 100644 --- a/python/.gitignore +++ b/python/.gitignore @@ -70,3 +70,4 @@ docs/_build/ # Pyenv .python-version +/.env From 3c364e9438965d8ad5e4ca260fd8a446379e06fb Mon Sep 17 00:00:00 2001 From: Otto Date: Sat, 8 Jun 2024 16:56:46 +0200 Subject: [PATCH 03/28] It's alive --- python/Cargo.toml | 1 + python/src/lib.rs | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/python/Cargo.toml b/python/Cargo.toml index ee680b31..a7364b78 100644 --- a/python/Cargo.toml +++ b/python/Cargo.toml @@ -10,3 +10,4 @@ crate-type = ["cdylib"] [dependencies] pyo3 = "0.21.1" +web-audio-api-rs = { path = "../", package = "web-audio-api" } diff --git a/python/src/lib.rs b/python/src/lib.rs index 6a3f1061..b9322a45 100644 --- a/python/src/lib.rs +++ b/python/src/lib.rs @@ -1,8 +1,16 @@ use pyo3::prelude::*; +use web_audio_api_rs::context::{AudioContext, BaseAudioContext}; +use web_audio_api_rs::node::{AudioNode, AudioScheduledSourceNode}; + /// Formats the sum of two numbers as string. #[pyfunction] fn sum_as_string(a: usize, b: usize) -> PyResult { + let ctx = AudioContext::default(); + let mut osc = ctx.create_oscillator(); + osc.connect(&ctx.destination()); + osc.start(); + Ok((a + b).to_string()) } From 559caba2a5ae2079c841f13cc0ab28a475432dbd Mon Sep 17 00:00:00 2001 From: Otto Date: Mon, 10 Jun 2024 21:10:44 +0200 Subject: [PATCH 04/28] Get OscillatorNode to work in Python --- Cargo.toml | 3 ++ python/Cargo.toml | 1 + python/README.md | 25 +++++++++++++ python/src/lib.rs | 93 ++++++++++++++++++++++++++++++++++++++++++----- 4 files changed, 112 insertions(+), 10 deletions(-) create mode 100644 python/README.md diff --git a/Cargo.toml b/Cargo.toml index fd873391..e114846d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,6 +17,9 @@ include = [ ] rust-version = "1.76" +[workspace] +members = ["python"] + [dependencies] almost = "0.2.0" arc-swap = "1.6" diff --git a/python/Cargo.toml b/python/Cargo.toml index a7364b78..57ec3eb6 100644 --- a/python/Cargo.toml +++ b/python/Cargo.toml @@ -7,6 +7,7 @@ edition = "2021" [lib] name = "web_audio_api" crate-type = ["cdylib"] +doc = false [dependencies] pyo3 = "0.21.1" diff --git a/python/README.md b/python/README.md new file mode 100644 index 00000000..1485e747 --- /dev/null +++ b/python/README.md @@ -0,0 +1,25 @@ +# Python bindings for web-audio-api-rs + +## Local development + +```bash +# cd to this directory + +# if not already, create a virtual env +python3 -m venv .env + +# enter the virtual env +source .env/bin/activate + +# (re)build the package +maturin develop +``` + +```python +import web_audio_api +ctx = web_audio_api.AudioContext() +osc = web_audio_api.OscillatorNode(ctx) +osc.connect(ctx.destination()) +osc.start() +osc.frequency().set_value(300) +``` diff --git a/python/src/lib.rs b/python/src/lib.rs index b9322a45..cb16ca7c 100644 --- a/python/src/lib.rs +++ b/python/src/lib.rs @@ -1,22 +1,95 @@ use pyo3::prelude::*; +use std::sync::{Arc, Mutex}; -use web_audio_api_rs::context::{AudioContext, BaseAudioContext}; -use web_audio_api_rs::node::{AudioNode, AudioScheduledSourceNode}; +use web_audio_api_rs::context::BaseAudioContext; +use web_audio_api_rs::node::{AudioNode as RsAudioNode, AudioScheduledSourceNode as _}; -/// Formats the sum of two numbers as string. -#[pyfunction] -fn sum_as_string(a: usize, b: usize) -> PyResult { - let ctx = AudioContext::default(); - let mut osc = ctx.create_oscillator(); - osc.connect(&ctx.destination()); - osc.start(); +#[pyclass] +struct AudioContext(web_audio_api_rs::context::AudioContext); - Ok((a + b).to_string()) +#[pymethods] +impl AudioContext { + #[new] + fn new() -> Self { + Self(Default::default()) + } + + fn destination(&self) -> AudioNode { + let dest = self.0.destination(); + let node = Arc::new(Mutex::new(dest)) as Arc>; + AudioNode(node) + } +} + +#[pyclass(subclass)] +struct AudioNode(Arc>); + +#[pymethods] +impl AudioNode { + fn connect(&self, other: &Self) { + self.0.lock().unwrap().connect(&*other.0.lock().unwrap()); + } + fn disconnect(&self, other: &Self) { + self.0 + .lock() + .unwrap() + .disconnect_dest(&*other.0.lock().unwrap()); + } +} + +#[pyclass] +struct AudioParam(web_audio_api_rs::AudioParam); + +#[pymethods] +impl AudioParam { + fn value(&self) -> f32 { + self.0.value() + } + + fn set_value(&self, value: f32) -> Self { + Self(self.0.set_value(value).clone()) + } +} + +#[pyclass(extends = AudioNode)] +struct OscillatorNode(Arc>); + +#[pymethods] +impl OscillatorNode { + #[new] + fn new(ctx: &AudioContext) -> (Self, AudioNode) { + let osc = ctx.0.create_oscillator(); + let node = Arc::new(Mutex::new(osc)); + let audio_node = Arc::clone(&node) as Arc>; + (OscillatorNode(node), AudioNode(audio_node)) + } + + #[pyo3(signature = (when=0.0))] + fn start(&mut self, when: f64) { + self.0.lock().unwrap().start_at(when) + } + + #[pyo3(signature = (when=0.0))] + fn stop(&mut self, when: f64) { + self.0.lock().unwrap().stop_at(when) + } + + fn frequency(&self) -> AudioParam { + AudioParam(self.0.lock().unwrap().frequency().clone()) + } + + fn detune(&self) -> AudioParam { + AudioParam(self.0.lock().unwrap().detune().clone()) + } } /// A Python module implemented in Rust. #[pymodule] fn web_audio_api(m: &Bound<'_, PyModule>) -> PyResult<()> { m.add_function(wrap_pyfunction!(sum_as_string, m)?)?; + m.add_class::()?; + m.add_class::()?; + m.add_class::()?; + m.add_class::()?; Ok(()) } From 9c0db75e216e835ac5da095bf3467ec2ec923ea2 Mon Sep 17 00:00:00 2001 From: Otto Date: Tue, 11 Jun 2024 07:54:12 +0200 Subject: [PATCH 05/28] Cleanup --- python/.github/workflows/CI.yml | 10 +++++----- python/src/lib.rs | 1 - 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/python/.github/workflows/CI.yml b/python/.github/workflows/CI.yml index 8a87af1e..453c0cb1 100644 --- a/python/.github/workflows/CI.yml +++ b/python/.github/workflows/CI.yml @@ -11,7 +11,7 @@ on: - main - master tags: - - '*' + - "*" pull_request: workflow_dispatch: @@ -46,7 +46,7 @@ jobs: with: target: ${{ matrix.platform.target }} args: --release --out dist --find-interpreter - sccache: 'true' + sccache: "true" manylinux: auto - name: Upload wheels uses: actions/upload-artifact@v4 @@ -77,7 +77,7 @@ jobs: with: target: ${{ matrix.platform.target }} args: --release --out dist --find-interpreter - sccache: 'true' + sccache: "true" manylinux: musllinux_1_2 - name: Upload wheels uses: actions/upload-artifact@v4 @@ -105,7 +105,7 @@ jobs: with: target: ${{ matrix.platform.target }} args: --release --out dist --find-interpreter - sccache: 'true' + sccache: "true" - name: Upload wheels uses: actions/upload-artifact@v4 with: @@ -131,7 +131,7 @@ jobs: with: target: ${{ matrix.platform.target }} args: --release --out dist --find-interpreter - sccache: 'true' + sccache: "true" - name: Upload wheels uses: actions/upload-artifact@v4 with: diff --git a/python/src/lib.rs b/python/src/lib.rs index cb16ca7c..5f3701f8 100644 --- a/python/src/lib.rs +++ b/python/src/lib.rs @@ -86,7 +86,6 @@ impl OscillatorNode { /// A Python module implemented in Rust. #[pymodule] fn web_audio_api(m: &Bound<'_, PyModule>) -> PyResult<()> { - m.add_function(wrap_pyfunction!(sum_as_string, m)?)?; m.add_class::()?; m.add_class::()?; m.add_class::()?; From a467764e3c3a1f74203469dab5b718e1ce535311 Mon Sep 17 00:00:00 2001 From: Otto Date: Tue, 11 Jun 2024 08:03:25 +0200 Subject: [PATCH 06/28] Update pyproject.toml --- python/pyproject.toml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/python/pyproject.toml b/python/pyproject.toml index 14ce3fc5..df7a30ea 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -3,13 +3,21 @@ requires = ["maturin>=1.6,<2.0"] build-backend = "maturin" [project] -name = "python" +name = "web-audio-api" +version = "0.1.0" requires-python = ">=3.8" +description = "A Rust/Python implementation of the Web Audio API, for use in non-browser contexts" +license = {text = "MIT License"} +keywords = ["web-audio-api", "audio", "sound", "dsp"] classifiers = [ "Programming Language :: Rust", - "Programming Language :: Python :: Implementation :: CPython", + "Topic :: Multimedia :: Sound/Audio", "Programming Language :: Python :: Implementation :: PyPy", ] -dynamic = ["version"] + +[project.urls] +Repository = "https://github.com/orottier/web-audio-api-rs" +Issues = "https://github.com/orottier/web-audio-api-rs/issues" + [tool.maturin] features = ["pyo3/extension-module"] From 427bec179fd5e862d0610905e3ad14426de8edcb Mon Sep 17 00:00:00 2001 From: Otto Date: Tue, 11 Jun 2024 08:10:01 +0200 Subject: [PATCH 07/28] Move python workflow to root, will probably fail --- python/.github/workflows/CI.yml | 169 -------------------------------- 1 file changed, 169 deletions(-) delete mode 100644 python/.github/workflows/CI.yml diff --git a/python/.github/workflows/CI.yml b/python/.github/workflows/CI.yml deleted file mode 100644 index 453c0cb1..00000000 --- a/python/.github/workflows/CI.yml +++ /dev/null @@ -1,169 +0,0 @@ -# This file is autogenerated by maturin v1.6.0 -# To update, run -# -# maturin generate-ci github -# -name: CI - -on: - push: - branches: - - main - - master - tags: - - "*" - pull_request: - workflow_dispatch: - -permissions: - contents: read - -jobs: - linux: - runs-on: ${{ matrix.platform.runner }} - strategy: - matrix: - platform: - - runner: ubuntu-latest - target: x86_64 - - runner: ubuntu-latest - target: x86 - - runner: ubuntu-latest - target: aarch64 - - runner: ubuntu-latest - target: armv7 - - runner: ubuntu-latest - target: s390x - - runner: ubuntu-latest - target: ppc64le - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: 3.x - - name: Build wheels - uses: PyO3/maturin-action@v1 - with: - target: ${{ matrix.platform.target }} - args: --release --out dist --find-interpreter - sccache: "true" - manylinux: auto - - name: Upload wheels - uses: actions/upload-artifact@v4 - with: - name: wheels-linux-${{ matrix.platform.target }} - path: dist - - musllinux: - runs-on: ${{ matrix.platform.runner }} - strategy: - matrix: - platform: - - runner: ubuntu-latest - target: x86_64 - - runner: ubuntu-latest - target: x86 - - runner: ubuntu-latest - target: aarch64 - - runner: ubuntu-latest - target: armv7 - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: 3.x - - name: Build wheels - uses: PyO3/maturin-action@v1 - with: - target: ${{ matrix.platform.target }} - args: --release --out dist --find-interpreter - sccache: "true" - manylinux: musllinux_1_2 - - name: Upload wheels - uses: actions/upload-artifact@v4 - with: - name: wheels-musllinux-${{ matrix.platform.target }} - path: dist - - windows: - runs-on: ${{ matrix.platform.runner }} - strategy: - matrix: - platform: - - runner: windows-latest - target: x64 - - runner: windows-latest - target: x86 - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: 3.x - architecture: ${{ matrix.platform.target }} - - name: Build wheels - uses: PyO3/maturin-action@v1 - with: - target: ${{ matrix.platform.target }} - args: --release --out dist --find-interpreter - sccache: "true" - - name: Upload wheels - uses: actions/upload-artifact@v4 - with: - name: wheels-windows-${{ matrix.platform.target }} - path: dist - - macos: - runs-on: ${{ matrix.platform.runner }} - strategy: - matrix: - platform: - - runner: macos-12 - target: x86_64 - - runner: macos-14 - target: aarch64 - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: 3.x - - name: Build wheels - uses: PyO3/maturin-action@v1 - with: - target: ${{ matrix.platform.target }} - args: --release --out dist --find-interpreter - sccache: "true" - - name: Upload wheels - uses: actions/upload-artifact@v4 - with: - name: wheels-macos-${{ matrix.platform.target }} - path: dist - - sdist: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Build sdist - uses: PyO3/maturin-action@v1 - with: - command: sdist - args: --out dist - - name: Upload sdist - uses: actions/upload-artifact@v4 - with: - name: wheels-sdist - path: dist - - release: - name: Release - runs-on: ubuntu-latest - if: "startsWith(github.ref, 'refs/tags/')" - needs: [linux, musllinux, windows, macos, sdist] - steps: - - uses: actions/download-artifact@v4 - - name: Publish to PyPI - uses: PyO3/maturin-action@v1 - env: - MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }} - with: - command: upload - args: --non-interactive --skip-existing wheels-*/* From 1aa6883a054102df9303d6bcc62eb84b9eabe33a Mon Sep 17 00:00:00 2001 From: Otto Date: Tue, 11 Jun 2024 08:14:05 +0200 Subject: [PATCH 08/28] Actually move GitHub workflow for Python --- .github/workflows/python.yaml | 168 ++++++++++++++++++++++++++++++++++ 1 file changed, 168 insertions(+) create mode 100644 .github/workflows/python.yaml diff --git a/.github/workflows/python.yaml b/.github/workflows/python.yaml new file mode 100644 index 00000000..bfabc527 --- /dev/null +++ b/.github/workflows/python.yaml @@ -0,0 +1,168 @@ +# This file is autogenerated by maturin v1.6.0 +# To update, run +# +# maturin generate-ci github +# +name: python + +on: + push: + branches: + - "*" + tags: + - "*" + pull_request: + workflow_dispatch: + +permissions: + contents: read + +jobs: + linux: + runs-on: ${{ matrix.platform.runner }} + strategy: + matrix: + platform: + - runner: ubuntu-latest + target: x86_64 + - runner: ubuntu-latest + target: x86 + - runner: ubuntu-latest + target: aarch64 + - runner: ubuntu-latest + target: armv7 + - runner: ubuntu-latest + target: s390x + - runner: ubuntu-latest + target: ppc64le + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: 3.x + - name: Build wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.platform.target }} + args: --release --out dist --find-interpreter + sccache: "true" + manylinux: auto + - name: Upload wheels + uses: actions/upload-artifact@v4 + with: + name: wheels-linux-${{ matrix.platform.target }} + path: dist + + musllinux: + runs-on: ${{ matrix.platform.runner }} + strategy: + matrix: + platform: + - runner: ubuntu-latest + target: x86_64 + - runner: ubuntu-latest + target: x86 + - runner: ubuntu-latest + target: aarch64 + - runner: ubuntu-latest + target: armv7 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: 3.x + - name: Build wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.platform.target }} + args: --release --out dist --find-interpreter + sccache: "true" + manylinux: musllinux_1_2 + - name: Upload wheels + uses: actions/upload-artifact@v4 + with: + name: wheels-musllinux-${{ matrix.platform.target }} + path: dist + + windows: + runs-on: ${{ matrix.platform.runner }} + strategy: + matrix: + platform: + - runner: windows-latest + target: x64 + - runner: windows-latest + target: x86 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: 3.x + architecture: ${{ matrix.platform.target }} + - name: Build wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.platform.target }} + args: --release --out dist --find-interpreter + sccache: "true" + - name: Upload wheels + uses: actions/upload-artifact@v4 + with: + name: wheels-windows-${{ matrix.platform.target }} + path: dist + + macos: + runs-on: ${{ matrix.platform.runner }} + strategy: + matrix: + platform: + - runner: macos-12 + target: x86_64 + - runner: macos-14 + target: aarch64 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: 3.x + - name: Build wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.platform.target }} + args: --release --out dist --find-interpreter + sccache: "true" + - name: Upload wheels + uses: actions/upload-artifact@v4 + with: + name: wheels-macos-${{ matrix.platform.target }} + path: dist + + sdist: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Build sdist + uses: PyO3/maturin-action@v1 + with: + command: sdist + args: --out dist + - name: Upload sdist + uses: actions/upload-artifact@v4 + with: + name: wheels-sdist + path: dist + + release: + name: Release + runs-on: ubuntu-latest + if: "startsWith(github.ref, 'refs/tags/')" + needs: [linux, musllinux, windows, macos, sdist] + steps: + - uses: actions/download-artifact@v4 + - name: Publish to PyPI + uses: PyO3/maturin-action@v1 + env: + MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }} + with: + command: upload + args: --non-interactive --skip-existing wheels-*/* From b796d5721b57b02f1322a6c9dd37a5fe88acff3c Mon Sep 17 00:00:00 2001 From: Otto Date: Tue, 11 Jun 2024 08:19:36 +0200 Subject: [PATCH 09/28] Python workflow: specify Cargo.toml manifest in subdirectory --- .github/workflows/python.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/python.yaml b/.github/workflows/python.yaml index bfabc527..73201462 100644 --- a/.github/workflows/python.yaml +++ b/.github/workflows/python.yaml @@ -44,7 +44,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.platform.target }} - args: --release --out dist --find-interpreter + args: --release --out dist --find-interpreter --manifest-path python/Cargo.toml sccache: "true" manylinux: auto - name: Upload wheels @@ -75,7 +75,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.platform.target }} - args: --release --out dist --find-interpreter + args: --release --out dist --find-interpreter --manifest-path python/Cargo.toml sccache: "true" manylinux: musllinux_1_2 - name: Upload wheels @@ -103,7 +103,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.platform.target }} - args: --release --out dist --find-interpreter + args: --release --out dist --find-interpreter --manifest-path python/Cargo.toml sccache: "true" - name: Upload wheels uses: actions/upload-artifact@v4 @@ -129,7 +129,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.platform.target }} - args: --release --out dist --find-interpreter + args: --release --out dist --find-interpreter --manifest-path python/Cargo.toml sccache: "true" - name: Upload wheels uses: actions/upload-artifact@v4 @@ -145,7 +145,7 @@ jobs: uses: PyO3/maturin-action@v1 with: command: sdist - args: --out dist + args: --out dist --manifest-path python/Cargo.toml - name: Upload sdist uses: actions/upload-artifact@v4 with: @@ -165,4 +165,4 @@ jobs: MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }} with: command: upload - args: --non-interactive --skip-existing wheels-*/* + args: --non-interactive --skip-existing wheels-*/* --manifest-path python/Cargo.toml From 4e6dc4c5a38f14b298b8145bd62ca428cc8d250f Mon Sep 17 00:00:00 2001 From: Otto Date: Tue, 11 Jun 2024 08:25:19 +0200 Subject: [PATCH 10/28] Python workflow: install Jack and Alsa on Linux runners --- .github/workflows/python.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/python.yaml b/.github/workflows/python.yaml index 73201462..328c9e9f 100644 --- a/.github/workflows/python.yaml +++ b/.github/workflows/python.yaml @@ -40,6 +40,9 @@ jobs: - uses: actions/setup-python@v5 with: python-version: 3.x + - name: Install ALSA and Jack dependencies + run: | + sudo apt-get update && sudo apt-get install -y libasound2-dev libjack-jackd2-dev cmake - name: Build wheels uses: PyO3/maturin-action@v1 with: @@ -71,6 +74,9 @@ jobs: - uses: actions/setup-python@v5 with: python-version: 3.x + - name: Install ALSA and Jack dependencies + run: | + sudo apt-get update && sudo apt-get install -y libasound2-dev libjack-jackd2-dev cmake - name: Build wheels uses: PyO3/maturin-action@v1 with: From 500a14679cb534ecf9779d22b5dbec17d3bd8c79 Mon Sep 17 00:00:00 2001 From: Otto Date: Tue, 11 Jun 2024 08:32:19 +0200 Subject: [PATCH 11/28] Python workflow: install pkg-config --- .github/workflows/python.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python.yaml b/.github/workflows/python.yaml index 328c9e9f..926a38ce 100644 --- a/.github/workflows/python.yaml +++ b/.github/workflows/python.yaml @@ -42,7 +42,7 @@ jobs: python-version: 3.x - name: Install ALSA and Jack dependencies run: | - sudo apt-get update && sudo apt-get install -y libasound2-dev libjack-jackd2-dev cmake + sudo apt-get update && sudo apt-get install -y pkg-config libasound2-dev libjack-jackd2-dev cmake - name: Build wheels uses: PyO3/maturin-action@v1 with: @@ -76,7 +76,7 @@ jobs: python-version: 3.x - name: Install ALSA and Jack dependencies run: | - sudo apt-get update && sudo apt-get install -y libasound2-dev libjack-jackd2-dev cmake + sudo apt-get update && sudo apt-get install -y pkg-config libasound2-dev libjack-jackd2-dev cmake - name: Build wheels uses: PyO3/maturin-action@v1 with: From 3902cce3203203ddf1b3a0aedc2c712dc91ab38c Mon Sep 17 00:00:00 2001 From: Otto Date: Tue, 11 Jun 2024 18:38:25 +0200 Subject: [PATCH 12/28] Python workflow: ignore musl build for now - fails on pkg-config --- .github/workflows/python.yaml | 71 ++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 34 deletions(-) diff --git a/.github/workflows/python.yaml b/.github/workflows/python.yaml index 926a38ce..3a164328 100644 --- a/.github/workflows/python.yaml +++ b/.github/workflows/python.yaml @@ -56,39 +56,41 @@ jobs: name: wheels-linux-${{ matrix.platform.target }} path: dist - musllinux: - runs-on: ${{ matrix.platform.runner }} - strategy: - matrix: - platform: - - runner: ubuntu-latest - target: x86_64 - - runner: ubuntu-latest - target: x86 - - runner: ubuntu-latest - target: aarch64 - - runner: ubuntu-latest - target: armv7 - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: 3.x - - name: Install ALSA and Jack dependencies - run: | - sudo apt-get update && sudo apt-get install -y pkg-config libasound2-dev libjack-jackd2-dev cmake - - name: Build wheels - uses: PyO3/maturin-action@v1 - with: - target: ${{ matrix.platform.target }} - args: --release --out dist --find-interpreter --manifest-path python/Cargo.toml - sccache: "true" - manylinux: musllinux_1_2 - - name: Upload wheels - uses: actions/upload-artifact@v4 - with: - name: wheels-musllinux-${{ matrix.platform.target }} - path: dist +# Ignore musl for now - issue with pkg-config installed but not found. +# +# musllinux: +# runs-on: ${{ matrix.platform.runner }} +# strategy: +# matrix: +# platform: +# - runner: ubuntu-latest +# target: x86_64 +# - runner: ubuntu-latest +# target: x86 +# - runner: ubuntu-latest +# target: aarch64 +# - runner: ubuntu-latest +# target: armv7 +# steps: +# - uses: actions/checkout@v4 +# - uses: actions/setup-python@v5 +# with: +# python-version: 3.x +# - name: Install ALSA and Jack dependencies +# run: | +# sudo apt-get update && sudo apt-get install -y pkg-config libasound2-dev libjack-jackd2-dev cmake +# - name: Build wheels +# uses: PyO3/maturin-action@v1 +# with: +# target: ${{ matrix.platform.target }} +# args: --release --out dist --find-interpreter --manifest-path python/Cargo.toml +# sccache: "true" +# manylinux: musllinux_1_2 +# - name: Upload wheels +# uses: actions/upload-artifact@v4 +# with: +# name: wheels-musllinux-${{ matrix.platform.target }} +# path: dist windows: runs-on: ${{ matrix.platform.runner }} @@ -162,7 +164,8 @@ jobs: name: Release runs-on: ubuntu-latest if: "startsWith(github.ref, 'refs/tags/')" - needs: [linux, musllinux, windows, macos, sdist] + # needs: [linux, musllinux, windows, macos, sdist] # musl ignored for now + needs: [linux, windows, macos, sdist] steps: - uses: actions/download-artifact@v4 - name: Publish to PyPI From 9b000338047feb33db8f3a39f53ff04e21405e09 Mon Sep 17 00:00:00 2001 From: Otto Date: Tue, 11 Jun 2024 18:45:21 +0200 Subject: [PATCH 13/28] Python workflow: install alsa as well --- .github/workflows/python.yaml | 72 +++++++++++++++++------------------ 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/.github/workflows/python.yaml b/.github/workflows/python.yaml index 3a164328..5d1a864b 100644 --- a/.github/workflows/python.yaml +++ b/.github/workflows/python.yaml @@ -42,7 +42,7 @@ jobs: python-version: 3.x - name: Install ALSA and Jack dependencies run: | - sudo apt-get update && sudo apt-get install -y pkg-config libasound2-dev libjack-jackd2-dev cmake + sudo apt-get update && sudo apt-get install -y pkg-config alsa libasound2-dev libjack-jackd2-dev cmake - name: Build wheels uses: PyO3/maturin-action@v1 with: @@ -56,41 +56,41 @@ jobs: name: wheels-linux-${{ matrix.platform.target }} path: dist -# Ignore musl for now - issue with pkg-config installed but not found. -# -# musllinux: -# runs-on: ${{ matrix.platform.runner }} -# strategy: -# matrix: -# platform: -# - runner: ubuntu-latest -# target: x86_64 -# - runner: ubuntu-latest -# target: x86 -# - runner: ubuntu-latest -# target: aarch64 -# - runner: ubuntu-latest -# target: armv7 -# steps: -# - uses: actions/checkout@v4 -# - uses: actions/setup-python@v5 -# with: -# python-version: 3.x -# - name: Install ALSA and Jack dependencies -# run: | -# sudo apt-get update && sudo apt-get install -y pkg-config libasound2-dev libjack-jackd2-dev cmake -# - name: Build wheels -# uses: PyO3/maturin-action@v1 -# with: -# target: ${{ matrix.platform.target }} -# args: --release --out dist --find-interpreter --manifest-path python/Cargo.toml -# sccache: "true" -# manylinux: musllinux_1_2 -# - name: Upload wheels -# uses: actions/upload-artifact@v4 -# with: -# name: wheels-musllinux-${{ matrix.platform.target }} -# path: dist + # Ignore musl for now - issue with pkg-config installed but not found. + # + # musllinux: + # runs-on: ${{ matrix.platform.runner }} + # strategy: + # matrix: + # platform: + # - runner: ubuntu-latest + # target: x86_64 + # - runner: ubuntu-latest + # target: x86 + # - runner: ubuntu-latest + # target: aarch64 + # - runner: ubuntu-latest + # target: armv7 + # steps: + # - uses: actions/checkout@v4 + # - uses: actions/setup-python@v5 + # with: + # python-version: 3.x + # - name: Install ALSA and Jack dependencies + # run: | + # sudo apt-get update && sudo apt-get install -y pkg-config alsa libasound2-dev libjack-jackd2-dev cmake + # - name: Build wheels + # uses: PyO3/maturin-action@v1 + # with: + # target: ${{ matrix.platform.target }} + # args: --release --out dist --find-interpreter --manifest-path python/Cargo.toml + # sccache: "true" + # manylinux: musllinux_1_2 + # - name: Upload wheels + # uses: actions/upload-artifact@v4 + # with: + # name: wheels-musllinux-${{ matrix.platform.target }} + # path: dist windows: runs-on: ${{ matrix.platform.runner }} From 413cb8853cb91c2f897a2eb7912ad3979d72a6cd Mon Sep 17 00:00:00 2001 From: Otto Date: Tue, 11 Jun 2024 18:57:41 +0200 Subject: [PATCH 14/28] Python workflow: install packages inside the Docker --- .github/workflows/python.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/python.yaml b/.github/workflows/python.yaml index 5d1a864b..f4aea467 100644 --- a/.github/workflows/python.yaml +++ b/.github/workflows/python.yaml @@ -40,15 +40,13 @@ jobs: - uses: actions/setup-python@v5 with: python-version: 3.x - - name: Install ALSA and Jack dependencies - run: | - sudo apt-get update && sudo apt-get install -y pkg-config alsa libasound2-dev libjack-jackd2-dev cmake - name: Build wheels uses: PyO3/maturin-action@v1 with: target: ${{ matrix.platform.target }} args: --release --out dist --find-interpreter --manifest-path python/Cargo.toml sccache: "true" + before-script-linux: sudo apt-get update && sudo apt-get install -y pkg-config libasound2-dev libjack-jackd2-dev cmake manylinux: auto - name: Upload wheels uses: actions/upload-artifact@v4 From b9194538099e3a8b3076a07e388e4878fad1780c Mon Sep 17 00:00:00 2001 From: Otto Date: Tue, 11 Jun 2024 18:59:57 +0200 Subject: [PATCH 15/28] Python workflow: do not sudo in Docker --- .github/workflows/python.yaml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/python.yaml b/.github/workflows/python.yaml index f4aea467..4d4a1875 100644 --- a/.github/workflows/python.yaml +++ b/.github/workflows/python.yaml @@ -46,7 +46,7 @@ jobs: target: ${{ matrix.platform.target }} args: --release --out dist --find-interpreter --manifest-path python/Cargo.toml sccache: "true" - before-script-linux: sudo apt-get update && sudo apt-get install -y pkg-config libasound2-dev libjack-jackd2-dev cmake + before-script-linux: apt-get update && apt-get install -y pkg-config libasound2-dev libjack-jackd2-dev cmake manylinux: auto - name: Upload wheels uses: actions/upload-artifact@v4 @@ -74,15 +74,13 @@ jobs: # - uses: actions/setup-python@v5 # with: # python-version: 3.x - # - name: Install ALSA and Jack dependencies - # run: | - # sudo apt-get update && sudo apt-get install -y pkg-config alsa libasound2-dev libjack-jackd2-dev cmake # - name: Build wheels # uses: PyO3/maturin-action@v1 # with: # target: ${{ matrix.platform.target }} # args: --release --out dist --find-interpreter --manifest-path python/Cargo.toml # sccache: "true" + # before-script-linux: apt-get update && apt-get install -y pkg-config libasound2-dev libjack-jackd2-dev cmake # manylinux: musllinux_1_2 # - name: Upload wheels # uses: actions/upload-artifact@v4 From 89051bf297d71c12dcaa1e653e7ece0a20c96457 Mon Sep 17 00:00:00 2001 From: Otto Date: Wed, 12 Jun 2024 08:23:35 +0200 Subject: [PATCH 16/28] Python workflow: linux image needs yum instead of apt? --- .github/workflows/python.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python.yaml b/.github/workflows/python.yaml index 4d4a1875..662ab53e 100644 --- a/.github/workflows/python.yaml +++ b/.github/workflows/python.yaml @@ -46,7 +46,7 @@ jobs: target: ${{ matrix.platform.target }} args: --release --out dist --find-interpreter --manifest-path python/Cargo.toml sccache: "true" - before-script-linux: apt-get update && apt-get install -y pkg-config libasound2-dev libjack-jackd2-dev cmake + before-script-linux: yum update && yum install -y pkg-config libasound2-dev manylinux: auto - name: Upload wheels uses: actions/upload-artifact@v4 @@ -80,7 +80,7 @@ jobs: # target: ${{ matrix.platform.target }} # args: --release --out dist --find-interpreter --manifest-path python/Cargo.toml # sccache: "true" - # before-script-linux: apt-get update && apt-get install -y pkg-config libasound2-dev libjack-jackd2-dev cmake + # before-script-linux: yum update && yum install -y pkg-config libasound2-dev # manylinux: musllinux_1_2 # - name: Upload wheels # uses: actions/upload-artifact@v4 From f1a9810ac22ff753c0b719a1b8aa43c278390c98 Mon Sep 17 00:00:00 2001 From: Otto Date: Wed, 12 Jun 2024 08:50:46 +0200 Subject: [PATCH 17/28] Python workflow: on run yum on Linux x64 and Arm, add -y --- .github/workflows/python.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/python.yaml b/.github/workflows/python.yaml index 662ab53e..ff24021b 100644 --- a/.github/workflows/python.yaml +++ b/.github/workflows/python.yaml @@ -31,10 +31,10 @@ jobs: target: aarch64 - runner: ubuntu-latest target: armv7 - - runner: ubuntu-latest - target: s390x - - runner: ubuntu-latest - target: ppc64le + # - runner: ubuntu-latest + # target: s390x + # - runner: ubuntu-latest + # target: ppc64le steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 @@ -46,7 +46,7 @@ jobs: target: ${{ matrix.platform.target }} args: --release --out dist --find-interpreter --manifest-path python/Cargo.toml sccache: "true" - before-script-linux: yum update && yum install -y pkg-config libasound2-dev + before-script-linux: yum update -y && yum install -y pkg-config libasound2-dev manylinux: auto - name: Upload wheels uses: actions/upload-artifact@v4 From cb07a5f153a036ea5c8c051e647efc4bc39ba646 Mon Sep 17 00:00:00 2001 From: Otto Date: Wed, 12 Jun 2024 17:00:15 +0200 Subject: [PATCH 18/28] Python workflow: do not install pkg-config on linux --- .github/workflows/python.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python.yaml b/.github/workflows/python.yaml index ff24021b..ea9b10b9 100644 --- a/.github/workflows/python.yaml +++ b/.github/workflows/python.yaml @@ -46,7 +46,7 @@ jobs: target: ${{ matrix.platform.target }} args: --release --out dist --find-interpreter --manifest-path python/Cargo.toml sccache: "true" - before-script-linux: yum update -y && yum install -y pkg-config libasound2-dev + before-script-linux: yum update -y && yum install -y libasound2-dev manylinux: auto - name: Upload wheels uses: actions/upload-artifact@v4 @@ -80,7 +80,7 @@ jobs: # target: ${{ matrix.platform.target }} # args: --release --out dist --find-interpreter --manifest-path python/Cargo.toml # sccache: "true" - # before-script-linux: yum update && yum install -y pkg-config libasound2-dev + # before-script-linux: yum update && yum install -y libasound2-dev # manylinux: musllinux_1_2 # - name: Upload wheels # uses: actions/upload-artifact@v4 From 662e16cce299579166127cab1096b1064a5dadf0 Mon Sep 17 00:00:00 2001 From: Otto Date: Wed, 12 Jun 2024 17:06:54 +0200 Subject: [PATCH 19/28] Python workflow: force install any alsa --- .github/workflows/python.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python.yaml b/.github/workflows/python.yaml index ea9b10b9..a615336d 100644 --- a/.github/workflows/python.yaml +++ b/.github/workflows/python.yaml @@ -46,7 +46,7 @@ jobs: target: ${{ matrix.platform.target }} args: --release --out dist --find-interpreter --manifest-path python/Cargo.toml sccache: "true" - before-script-linux: yum update -y && yum install -y libasound2-dev + before-script-linux: yum update -y && yum install --skip-broken -y libasound2-dev libasound2 manylinux: auto - name: Upload wheels uses: actions/upload-artifact@v4 @@ -80,7 +80,7 @@ jobs: # target: ${{ matrix.platform.target }} # args: --release --out dist --find-interpreter --manifest-path python/Cargo.toml # sccache: "true" - # before-script-linux: yum update && yum install -y libasound2-dev + # before-script-linux: yum update -y && yum install --skip-broken -y libasound2-dev libasound2 # manylinux: musllinux_1_2 # - name: Upload wheels # uses: actions/upload-artifact@v4 From 35a2252949964cd3d54d1c7be3c47f0b8fb51a84 Mon Sep 17 00:00:00 2001 From: Otto Date: Wed, 12 Jun 2024 17:13:31 +0200 Subject: [PATCH 20/28] Python workflow: install different alsa dep --- .github/workflows/python.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python.yaml b/.github/workflows/python.yaml index a615336d..f517adca 100644 --- a/.github/workflows/python.yaml +++ b/.github/workflows/python.yaml @@ -46,7 +46,7 @@ jobs: target: ${{ matrix.platform.target }} args: --release --out dist --find-interpreter --manifest-path python/Cargo.toml sccache: "true" - before-script-linux: yum update -y && yum install --skip-broken -y libasound2-dev libasound2 + before-script-linux: yum update -y && yum install -y alsa-utils alsa-lib manylinux: auto - name: Upload wheels uses: actions/upload-artifact@v4 @@ -80,7 +80,7 @@ jobs: # target: ${{ matrix.platform.target }} # args: --release --out dist --find-interpreter --manifest-path python/Cargo.toml # sccache: "true" - # before-script-linux: yum update -y && yum install --skip-broken -y libasound2-dev libasound2 + # before-script-linux: yum update -y && yum install -y alsa-utils alsa-lib # manylinux: musllinux_1_2 # - name: Upload wheels # uses: actions/upload-artifact@v4 From ecf7613091fc5a4c1f07ffb9e9a12198a460ca57 Mon Sep 17 00:00:00 2001 From: Otto Date: Wed, 12 Jun 2024 17:17:46 +0200 Subject: [PATCH 21/28] Python workflow: ARM pkg-config does not support cross compile --- .github/workflows/python.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/python.yaml b/.github/workflows/python.yaml index f517adca..501fc17b 100644 --- a/.github/workflows/python.yaml +++ b/.github/workflows/python.yaml @@ -27,10 +27,10 @@ jobs: target: x86_64 - runner: ubuntu-latest target: x86 - - runner: ubuntu-latest - target: aarch64 - - runner: ubuntu-latest - target: armv7 + # - runner: ubuntu-latest + # target: aarch64 + # - runner: ubuntu-latest + # target: armv7 # - runner: ubuntu-latest # target: s390x # - runner: ubuntu-latest @@ -46,7 +46,7 @@ jobs: target: ${{ matrix.platform.target }} args: --release --out dist --find-interpreter --manifest-path python/Cargo.toml sccache: "true" - before-script-linux: yum update -y && yum install -y alsa-utils alsa-lib + before-script-linux: yum update -y && yum install -y alsa alsa-dev alsa-utils alsa-lib manylinux: auto - name: Upload wheels uses: actions/upload-artifact@v4 From 87e485249db3fe64758d7efe9e4285b24169c673 Mon Sep 17 00:00:00 2001 From: Otto Date: Wed, 12 Jun 2024 17:20:06 +0200 Subject: [PATCH 22/28] Why suggest to install `alsa` when it does not exist --- .github/workflows/python.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python.yaml b/.github/workflows/python.yaml index 501fc17b..9a8c3f04 100644 --- a/.github/workflows/python.yaml +++ b/.github/workflows/python.yaml @@ -46,7 +46,7 @@ jobs: target: ${{ matrix.platform.target }} args: --release --out dist --find-interpreter --manifest-path python/Cargo.toml sccache: "true" - before-script-linux: yum update -y && yum install -y alsa alsa-dev alsa-utils alsa-lib + before-script-linux: yum update -y && yum install -y alsa-dev alsa-utils alsa-lib manylinux: auto - name: Upload wheels uses: actions/upload-artifact@v4 From 40a0e3fef73f758145df24694cbcc6ab9d799c4e Mon Sep 17 00:00:00 2001 From: Otto Date: Wed, 12 Jun 2024 17:24:05 +0200 Subject: [PATCH 23/28] Python workflow: just ignore linux --- .github/workflows/python.yaml | 77 ++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 38 deletions(-) diff --git a/.github/workflows/python.yaml b/.github/workflows/python.yaml index 9a8c3f04..6ecfaba7 100644 --- a/.github/workflows/python.yaml +++ b/.github/workflows/python.yaml @@ -18,42 +18,43 @@ permissions: contents: read jobs: - linux: - runs-on: ${{ matrix.platform.runner }} - strategy: - matrix: - platform: - - runner: ubuntu-latest - target: x86_64 - - runner: ubuntu-latest - target: x86 - # - runner: ubuntu-latest - # target: aarch64 - # - runner: ubuntu-latest - # target: armv7 - # - runner: ubuntu-latest - # target: s390x - # - runner: ubuntu-latest - # target: ppc64le - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: 3.x - - name: Build wheels - uses: PyO3/maturin-action@v1 - with: - target: ${{ matrix.platform.target }} - args: --release --out dist --find-interpreter --manifest-path python/Cargo.toml - sccache: "true" - before-script-linux: yum update -y && yum install -y alsa-dev alsa-utils alsa-lib - manylinux: auto - - name: Upload wheels - uses: actions/upload-artifact@v4 - with: - name: wheels-linux-${{ matrix.platform.target }} - path: dist - + # Ignore linux for now - cannot install Alsa? + # linux: + # runs-on: ${{ matrix.platform.runner }} + # strategy: + # matrix: + # platform: + # - runner: ubuntu-latest + # target: x86_64 + # - runner: ubuntu-latest + # target: x86 + # # - runner: ubuntu-latest + # # target: aarch64 + # # - runner: ubuntu-latest + # # target: armv7 + # # - runner: ubuntu-latest + # # target: s390x + # # - runner: ubuntu-latest + # # target: ppc64le + # steps: + # - uses: actions/checkout@v4 + # - uses: actions/setup-python@v5 + # with: + # python-version: 3.x + # - name: Build wheels + # uses: PyO3/maturin-action@v1 + # with: + # target: ${{ matrix.platform.target }} + # args: --release --out dist --find-interpreter --manifest-path python/Cargo.toml + # sccache: "true" + # before-script-linux: yum update -y && yum install -y alsa-dev alsa-utils alsa-lib + # manylinux: auto + # - name: Upload wheels + # uses: actions/upload-artifact@v4 + # with: + # name: wheels-linux-${{ matrix.platform.target }} + # path: dist + # # Ignore musl for now - issue with pkg-config installed but not found. # # musllinux: @@ -160,8 +161,8 @@ jobs: name: Release runs-on: ubuntu-latest if: "startsWith(github.ref, 'refs/tags/')" - # needs: [linux, musllinux, windows, macos, sdist] # musl ignored for now - needs: [linux, windows, macos, sdist] + # needs: [linux, musllinux, windows, macos, sdist] # musl and linux ignored for now + needs: [windows, macos, sdist] steps: - uses: actions/download-artifact@v4 - name: Publish to PyPI From eb30733f329725d41b75760df191be6b6336f5c2 Mon Sep 17 00:00:00 2001 From: Otto Date: Wed, 12 Jun 2024 17:30:28 +0200 Subject: [PATCH 24/28] Python workflow: manual release --- .github/workflows/python.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/python.yaml b/.github/workflows/python.yaml index 6ecfaba7..a3a7e22e 100644 --- a/.github/workflows/python.yaml +++ b/.github/workflows/python.yaml @@ -160,7 +160,8 @@ jobs: release: name: Release runs-on: ubuntu-latest - if: "startsWith(github.ref, 'refs/tags/')" + workflow_dispatch: + # if: "startsWith(github.ref, 'refs/tags/')" # needs: [linux, musllinux, windows, macos, sdist] # musl and linux ignored for now needs: [windows, macos, sdist] steps: From 832ca5950c8b23696ef80f4a2ab3f50082e77833 Mon Sep 17 00:00:00 2001 From: Otto Date: Wed, 12 Jun 2024 17:35:23 +0200 Subject: [PATCH 25/28] Python workflow: auto-release (once) --- .github/workflows/python.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/python.yaml b/.github/workflows/python.yaml index a3a7e22e..d4d894ac 100644 --- a/.github/workflows/python.yaml +++ b/.github/workflows/python.yaml @@ -160,7 +160,6 @@ jobs: release: name: Release runs-on: ubuntu-latest - workflow_dispatch: # if: "startsWith(github.ref, 'refs/tags/')" # needs: [linux, musllinux, windows, macos, sdist] # musl and linux ignored for now needs: [windows, macos, sdist] From c930e96fc126b474e832d52afc66241fbea2f8e5 Mon Sep 17 00:00:00 2001 From: Otto Date: Wed, 12 Jun 2024 20:01:22 +0200 Subject: [PATCH 26/28] Python workflow: when releasing, do not specify manifest-path --- .github/workflows/python.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python.yaml b/.github/workflows/python.yaml index d4d894ac..1bd99b9f 100644 --- a/.github/workflows/python.yaml +++ b/.github/workflows/python.yaml @@ -171,4 +171,4 @@ jobs: MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }} with: command: upload - args: --non-interactive --skip-existing wheels-*/* --manifest-path python/Cargo.toml + args: --non-interactive --skip-existing wheels-*/* From 5077198036b07c905f6088ea77b9b57d28c24e1a Mon Sep 17 00:00:00 2001 From: Otto Date: Thu, 13 Jun 2024 20:25:37 +0200 Subject: [PATCH 27/28] Python: use getter/setter for AudioParam value --- python/main.py | 15 +++++++++++++++ python/src/lib.rs | 11 +++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 python/main.py diff --git a/python/main.py b/python/main.py new file mode 100644 index 00000000..6292f713 --- /dev/null +++ b/python/main.py @@ -0,0 +1,15 @@ +import web_audio_api +from time import sleep + +ctx = web_audio_api.AudioContext() +osc = web_audio_api.OscillatorNode(ctx) +osc.connect(ctx.destination()) +osc.start() + +print("freq =", osc.frequency().value); +sleep(4) + +osc.frequency().value = 300 +print("freq =", osc.frequency().value); + +sleep(4) diff --git a/python/src/lib.rs b/python/src/lib.rs index 5f3701f8..2dea4132 100644 --- a/python/src/lib.rs +++ b/python/src/lib.rs @@ -42,12 +42,15 @@ struct AudioParam(web_audio_api_rs::AudioParam); #[pymethods] impl AudioParam { - fn value(&self) -> f32 { - self.0.value() + #[getter] + fn value(&self) -> PyResult { + Ok(self.0.value()) } - fn set_value(&self, value: f32) -> Self { - Self(self.0.set_value(value).clone()) + #[setter] + fn set_value(&self, value: f32) -> PyResult<()> { + self.0.set_value(value); + Ok(()) } } From 330a7f7bc6eba52851d14769210dcc1fc290388b Mon Sep 17 00:00:00 2001 From: Otto Date: Sat, 15 Jun 2024 20:43:34 +0200 Subject: [PATCH 28/28] Python workflow: revert to only release on tags This reverts commit 1209584841240b8e9b52852df5fa348367220f2f. --- .github/workflows/python.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python.yaml b/.github/workflows/python.yaml index 1bd99b9f..7efe6142 100644 --- a/.github/workflows/python.yaml +++ b/.github/workflows/python.yaml @@ -160,7 +160,7 @@ jobs: release: name: Release runs-on: ubuntu-latest - # if: "startsWith(github.ref, 'refs/tags/')" + if: "startsWith(github.ref, 'refs/tags/')" # needs: [linux, musllinux, windows, macos, sdist] # musl and linux ignored for now needs: [windows, macos, sdist] steps: