Skip to content

Commit

Permalink
bump examples to PyO3 0.22, support Python 3.13
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhewitt committed Jul 1, 2024
1 parent 34c5f16 commit c77caee
Show file tree
Hide file tree
Showing 18 changed files with 164 additions and 670 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
# If one platform fails, allow the rest to keep testing if `CI-no-fail-fast` label is present
fail-fast: ${{ !contains(github.event.pull_request.labels.*.name, 'CI-no-fail-fast') }}
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", pypy-3.8, pypy-3.9, pypy-3.10]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", pypy-3.8, pypy-3.9, pypy-3.10]
platform: [
{ os: "macos-latest", python-architecture: "arm64", rust-target: "aarch64-apple-darwin" },
{ os: "ubuntu-latest", python-architecture: "x64", rust-target: "x86_64-unknown-linux-gnu" },
Expand Down Expand Up @@ -91,6 +91,7 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.platform.python-architecture }}
allow-prereleases: true

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Changelog

## Unreleased
### Packaging
- Support Python 3.13. [#446](https://github.com/PyO3/setuptools-rust/pull/446)

### Changed
- Use the base interpreter path when running inside a virtual environment to avoid recompilation when switching between virtual environments. [#429](https://github.com/PyO3/setuptools-rust/pull/429)
- Delay import of dependencies until use to avoid import errors during a partially complete install when multiple packages are installing at once. [#437](https://github.com/PyO3/setuptools-rust/pull/437)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ version = "0.1.0"
edition = "2021"

[dependencies]
pyo3 = "0.20.3"
pyo3 = "0.22.0"

[lib]
name = "_lib" # private module to be nested into Python package,
Expand Down
150 changes: 13 additions & 137 deletions examples/hello-world-setuppy/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/hello-world-setuppy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021"

[dependencies]
pyo3 = "0.21.0"
pyo3 = "0.22.0"

[lib]
# See https://github.com/PyO3/pyo3 for details
Expand Down
17 changes: 8 additions & 9 deletions examples/hello-world-setuppy/rust/lib.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
use pyo3::prelude::*;

/// Formats the sum of two numbers as string.
#[pyfunction]
fn sum_as_string(a: usize, b: usize) -> PyResult<String> {
Ok((a + b).to_string())
}

/// A Python module implemented in Rust. The name of this function must match
/// the `lib.name` setting in the `Cargo.toml`, else Python will not be able to
/// import the module.
#[pymodule]
fn _lib(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
m.add_function(wrap_pyfunction!(sum_as_string, m)?)?;
Ok(())
mod _lib {
use pyo3::prelude::*;

/// Formats the sum of two numbers as string.
#[pyfunction]
fn sum_as_string(a: usize, b: usize) -> PyResult<String> {
Ok((a + b).to_string())
}
}
Loading

0 comments on commit c77caee

Please sign in to comment.