Skip to content
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
6 changes: 6 additions & 0 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ message = release: {new_version}
[bumpversion:file:pyproject.toml]

[bumpversion:file:setuptools_rust/version.py]

[bumpversion:file:uv.lock]
search = name = "setuptools-rust"
version = "{current_version}"
replace = name = "setuptools-rust"
version = "{new_version}"
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ updates:
patterns:
- "*"

- package-ecosystem: "uv"
directory: "/"
schedule:
interval: "monthly"
allow:
- dependency-type: "all"
groups:
python-dependencies:
patterns:
- "*"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
Expand Down
34 changes: 19 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ jobs:
with:
python-version: "3.x"

- run: pip install nox
- uses: astral-sh/setup-uv@1db35dd8eee11c5894872e0b383ae6c406cf738d # v10.4.0
with:
version-file: "uv.lock"

- run: nox -s mypy
- run: uv run --locked --only-group mypy mypy setuptools_rust

pytest:
runs-on: "ubuntu-latest"
Expand Down Expand Up @@ -134,32 +136,37 @@ jobs:

env:
SETUPTOOLS_RUST_CARGO_PROFILE: dev
NOX_DEFAULT_VENV_BACKEND: uv
steps:
- uses: actions/checkout@v7

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v7
id: setup-python
# Fix python-path on Windows GraalPy: https://github.com/actions/setup-python/pull/1393
uses: davidhewitt/setup-python@c865f403b97f90f93775f8cd8e4c15b9ace54119
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.platform.python-architecture }}
allow-prereleases: true

- uses: astral-sh/setup-uv@1db35dd8eee11c5894872e0b383ae6c406cf738d # v10.4.0
with:
version-file: "uv.lock"

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.platform.rust-target }}

- name: Install test dependencies
run: pip install --upgrade nox

- name: Build package
run: pip install -e .

- name: Test examples
shell: bash
env:
PYTHON: ${{ matrix.python-version }}
run: nox -s test-examples
CI_PYTHON: ${{ steps.setup-python.outputs.python-path }}
run: uv run --locked --only-group ci --no-build --python "$CI_PYTHON" nox -s test-examples

- name: Test macOS universal2
if: ${{ startsWith(matrix.platform.os, 'macos') && !startsWith(matrix.python-version, 'pypy') && !startsWith(matrix.python-version, 'graalpy') }}
Expand All @@ -180,11 +187,12 @@ jobs:

- name: Test sdist vendor Rust crates
shell: bash
run: nox -s test-sdist-vendor
run: uv run --locked --only-group ci --no-build --python "$CI_PYTHON" nox -s test-sdist-vendor
# FIXME: graalpy on windows appears to have issues with the sdist process, needs investigation and
# reporting upstream.
continue-on-error: ${{ matrix.platform.os == 'windows-latest' && startsWith(matrix.python-version, 'graalpy') }}
env:
CI_PYTHON: ${{ steps.setup-python.outputs.python-path }}
CARGO_BUILD_TARGET: ${{ matrix.platform.rust-target }}

test-abi3:
Expand All @@ -207,7 +215,9 @@ jobs:
- name: Setup python
uses: actions/setup-python@v7
with:
python-version: "3.x"
# On Python 3.15, setuptools uses a qualified ABI3 suffix that Python 3.11 cannot import.
# https://github.com/pypa/setuptools/issues/5389
python-version: "3.14"

- uses: dtolnay/rust-toolchain@stable

Expand Down Expand Up @@ -370,12 +380,6 @@ jobs:
path: mingw64,
rust_target: x86_64-pc-windows-gnu,
},
{
msystem: MINGW32,
arch: i686,
path: mingw32,
rust_target: i686-pc-windows-gnu,
},
]
env:
CARGO_BUILD_TARGET: ${{ matrix.rust_target }}
Expand Down
8 changes: 3 additions & 5 deletions examples/hello-world/rust/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use pyo3::prelude::*;
#[pymodule]
mod _lib {
use pyo3::prelude::*;
use std::env;

/// Formats the sum of two numbers as string.
#[pyfunction]
Expand All @@ -17,15 +16,14 @@ mod _lib {
/// Calls Python (see https://pyo3.rs for details)
#[pyfunction]
fn demo(py: Python) -> PyResult<()> {
let argv = env::args().collect::<Vec<_>>();
let argv: Vec<String> = py.import("sys")?.getattr("argv")?.extract()?;
println!("argv = {:?}", argv);
// argv[0]: Python path, argv[1]: program name, argv[2..]: given args

let numbers: Vec<i32> = argv[2..].iter().map(|s| s.parse().unwrap()).collect();
let numbers: Vec<i32> = argv[1..].iter().map(|s| s.parse().unwrap()).collect();

let python_sum = PyModule::import(py, "builtins")?.getattr("sum")?;
let total: i32 = python_sum.call1((numbers,))?.extract()?;
println!("sum({}) = {:?}", argv[2..].join(", "), total);
println!("sum({}) = {:?}", argv[1..].join(", "), total);
Ok(())
}
}
23 changes: 14 additions & 9 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,8 @@ def test_sdist_vendor(session: nox.Session):
cmd = ["python", "-m", "build", "--sdist", "--no-isolation"]
session.run(*cmd, env=env, external=True)

session.run(
"python",
"-m",
"pip",
"install",
Path("dist") / "namespace_package-0.1.0.tar.gz[dev]",
session.install(
str(Path("dist") / "namespace_package-0.1.0.tar.gz[dev]"),
"--no-build-isolation",
"-v",
# run in offline mode with a blank cargo home to prove the vendored
Expand Down Expand Up @@ -215,10 +211,19 @@ def ruff(session: nox.Session):
session.run("ruff", "check", ".")


@nox.session()
@nox.session(venv_backend="none")
def mypy(session: nox.Session):
session.install("mypy", "fat_macho", "types-setuptools", ".")
session.run("mypy", "setuptools_rust", *session.posargs)
session.run(
"uv",
"run",
"--locked",
"--only-group",
"mypy",
"mypy",
"setuptools_rust",
*session.posargs,
external=True,
)


@nox.session()
Expand Down
7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ Changelog = "https://github.com/PyO3/setuptools-rust/blob/main/CHANGELOG.md"
requires = ["setuptools>=62.4", "setuptools_scm"]
build-backend = "setuptools.build_meta"

[dependency-groups]
ci = ["nox"]
build = ["setuptools>=62.4", "setuptools_scm"]
mypy = ["mypy", "fat_macho", "types-setuptools"]
# setup-uv reads the locked version without installing it into the CI environment.
bootstrap = ["uv"]

[tool.ruff.lint]
extend-select = ["TID251"]

Expand Down
2 changes: 1 addition & 1 deletion setuptools_rust/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ def get_dylib_ext_path(self, ext: RustExtension, target_fname: str) -> str:
if abi3_suffix is not None:
so_ext = get_config_var("EXT_SUFFIX")
assert isinstance(so_ext, str)
ext_path = ext_path[: -len(so_ext)] + get_abi3_suffix()
ext_path = ext_path[: -len(so_ext)] + abi3_suffix

if ".abi3." in ext_path:
return ext_path
Expand Down
Loading
Loading