Skip to content

Commit eea1898

Browse files
authored
feat: distribute future-compatible python wheels (#80)
This ensures future-compatibility with newer Python versions without having to re-deploy the python binding when a new Python version reaches stable status. This uses pyo3 crate's `abi3-py39` feature. Meaning, the minimum supported Python version remains v3.9.x. * note support for `UV_NO_DEV` env var in python binding README * bump pip deps and update uv.lock * make CI fail on rust lint warnings * replace deprecated pyo3 API
1 parent dc0d58d commit eea1898

File tree

6 files changed

+77
-71
lines changed

6 files changed

+77
-71
lines changed

.github/workflows/pre-commit.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ jobs:
3434
with:
3535
path: ~/.cargo
3636
key: cargo-lint-${{ hashFiles('**/*.rs') }}
37-
- run: cargo clippy
38-
- run: cargo clippy -p examples
37+
- run: cargo clippy -- -D warnings
38+
- run: cargo clippy -p examples -- -D warnings
3939
- run: cargo fmt --check --all
4040

4141
lint-typescript:

bindings/python/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ crate-type = ["cdylib"]
1414

1515
[dependencies]
1616
embedded-hal = "1.0.0"
17-
pyo3 = {version = "0.25.1", features = ["extension-module"]}
17+
pyo3 = {version = "0.26.0", features = ["extension-module", "abi3-py39"]}
1818
rf24-rs = { path = "../../crates/rf24-rs", features = ["std"]}
1919
rf24ble-rs = { path = "../../crates/rf24ble-rs", features = ["std"] }
2020

bindings/python/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ To build from source, the [rf24-rs] project uses [uv] to manage dependencies:
3636
uv sync
3737
```
3838

39-
Append `--no-dev` for environments with limited disk space (eg. Raspberry Pi machine).
39+
Append `--no-dev` (or set `UV_NO_DEV=1` environment variable) for environments with limited disk space (eg. Raspberry Pi machine).
40+
As of [uv] v0.8.7, the environment variable
4041

4142
[uv]: https://docs.astral.sh/uv
4243

@@ -49,8 +50,9 @@ To run the examples, simply pass the example file's path to the python interpret
4950
uv run examples/python/getting_started.py
5051
```
5152

52-
Again, the `--no-dev` argument can be applied to the `uv run` command for
53-
environments with limited disk space.
53+
Again, the `--no-dev` argument can be applied to the `uv run` command
54+
(or set `UV_NO_DEV=1` environment variable)
55+
for environments with limited disk space.
5456

5557
The examples/python/irq_config.py script requires the [gpiod] package.
5658
The `uv run` command needs to be amended to include this dependency:

bindings/python/src/fake_ble/radio.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ impl FakeBle {
121121
/// This function should not be called in RX mode. To ensure proper radio behavior,
122122
/// the caller must ensure that the radio is in TX mode.
123123
pub fn hop_channel(&mut self) -> PyResult<()> {
124-
Python::with_gil(|py| {
124+
Python::attach(|py| {
125125
let mut radio = self.radio.bind(py).borrow_mut();
126126
let channel = radio.get_channel()?;
127127
if let Some(channel) = BleChannels::increment(channel) {
@@ -151,7 +151,7 @@ impl FakeBle {
151151
/// | `1` | `0xFF` |
152152
/// | `2 ... n - 1` | custom data |
153153
pub fn send(&mut self, buf: &[u8]) -> PyResult<bool> {
154-
Python::with_gil(|py| {
154+
Python::attach(|py| {
155155
let mut radio = self.radio.bind(py).borrow_mut();
156156
if let Some(tx_queue) = self.inner.make_payload(
157157
buf,
@@ -185,7 +185,7 @@ impl FakeBle {
185185
/// If the payload was somehow malformed or incomplete,
186186
/// then this function returns an `None` value.
187187
pub fn read(&mut self) -> PyResult<Option<BlePayload>> {
188-
Python::with_gil(|py| {
188+
Python::attach(|py| {
189189
let mut radio = self.radio.bind(py).borrow_mut();
190190
let mut buf = [0u8; 32];
191191
buf.copy_from_slice(&radio.read(Some(32))?);

pyproject.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,16 @@ include = [
6464

6565
[dependency-groups]
6666
dev = [
67-
"maturin==1.9.2",
67+
"maturin==1.9.4",
6868
"mypy==1.17.1",
69-
"pre-commit==4.2.0",
70-
"ruff==0.12.7",
69+
"pre-commit==4.3.0",
70+
"ruff==0.12.11",
7171
]
7272
docs = [
7373
"markdown-gfm-admonition==0.1.1",
7474
"mkdocs==1.6.1",
75-
"mkdocs-include-markdown-plugin==7.1.6",
76-
"mkdocs-material==9.6.16",
77-
"mkdocstrings-python==1.16.12",
75+
"mkdocs-include-markdown-plugin==7.1.7",
76+
"mkdocs-material==9.6.18",
77+
"mkdocstrings-python==1.18.2",
7878
"pymdown-extensions==10.16.1",
7979
]

0 commit comments

Comments
 (0)