Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: PyO3/maturin
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.3.0
Choose a base ref
...
head repository: PyO3/maturin
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.3.1
Choose a head ref
  • 16 commits
  • 18 files changed
  • 8 contributors

Commits on Oct 4, 2023

  1. CI: Add Python 3.12 test jobs (#1276)

    * CI: Add Python 3.12 test jobs
    
    * Use Python 3.12 release version
    
    * Fix typo: compaible -> compatible
    
    ---------
    
    Co-authored-by: konstin <konstin@mailbox.org>
    messense and konstin authored Oct 4, 2023
    Copy the full SHA
    2e7e8ef View commit details
  2. Use external uniffi-bindgen if no root package is configured (#1797)

    A "root package" in Cargo exists in a workspace if the workspace
    Cargo.toml also has a `[package]` section.
    In that case maturin tries to find a binary target called
    `uniffi-bindgen` to use.
    
    But if there's no root package to begin with it should fall back to an
    external `uniffi-bindgen` instead of panicking.
    badboy authored Oct 4, 2023
    Copy the full SHA
    189852c View commit details

Commits on Oct 6, 2023

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    3fc4ae3 View commit details

Commits on Oct 9, 2023

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    6cad535 View commit details

Commits on Oct 10, 2023

  1. [pre-commit.ci] pre-commit autoupdate (#1801)

    updates:
    - [github.com/pre-commit/pre-commit-hooks: v4.4.0 → v4.5.0](pre-commit/pre-commit-hooks@v4.4.0...v4.5.0)
    - [github.com/astral-sh/ruff-pre-commit: v0.0.291 → v0.0.292](astral-sh/ruff-pre-commit@v0.0.291...v0.0.292)
    - [github.com/codespell-project/codespell: v2.2.5 → v2.2.6](codespell-project/codespell@v2.2.5...v2.2.6)
    
    Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
    pre-commit-ci[bot] authored Oct 10, 2023
    Copy the full SHA
    1123fa0 View commit details
  2. Copy the full SHA
    2382ab3 View commit details

Commits on Oct 11, 2023

  1. Copy the full SHA
    8d4b482 View commit details

Commits on Oct 17, 2023

  1. [pre-commit.ci] pre-commit autoupdate (#1806)

    updates:
    - [github.com/pre-commit/mirrors-mypy: v1.5.1 → v1.6.0](pre-commit/mirrors-mypy@v1.5.1...v1.6.0)
    
    Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
    pre-commit-ci[bot] authored Oct 17, 2023
    Copy the full SHA
    2536fff View commit details
  2. Copy the full SHA
    a41f24d View commit details
  3. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    2cb2274 View commit details

Commits on Oct 19, 2023

  1. Bump rustix from 0.37.23 to 0.37.25 (#1809)

    Bumps [rustix](https://github.com/bytecodealliance/rustix) from 0.37.23 to 0.37.25.
    - [Release notes](https://github.com/bytecodealliance/rustix/releases)
    - [Commits](bytecodealliance/rustix@v0.37.23...v0.37.25)
    
    ---
    updated-dependencies:
    - dependency-name: rustix
      dependency-type: indirect
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Oct 19, 2023
    Copy the full SHA
    ab4578c View commit details
  2. Auto detect Python 3.13 (#1810)

    * Auto detect Python 3.13
    
    Now that Python 3.13 has an alpha release.
    
    * Fix a test case
    messense authored Oct 19, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    177d40f View commit details
  3. Fix missing workspace.members in sdist (#1811)

    Previously it only compares the directory name with known path deps,
    but it should compare using the full path.
    messense authored Oct 19, 2023
    Copy the full SHA
    728698d View commit details

Commits on Oct 24, 2023

  1. [pre-commit.ci] pre-commit autoupdate (#1813)

    updates:
    - [github.com/psf/black: 23.9.1 → 23.10.0](psf/black@23.9.1...23.10.0)
    - [github.com/astral-sh/ruff-pre-commit: v0.0.292 → v0.1.1](astral-sh/ruff-pre-commit@v0.0.292...v0.1.1)
    - [github.com/pre-commit/mirrors-mypy: v1.6.0 → v1.6.1](pre-commit/mirrors-mypy@v1.6.0...v1.6.1)
    
    Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
    pre-commit-ci[bot] authored Oct 24, 2023
    Copy the full SHA
    6edc084 View commit details
  2. Copy the full SHA
    a8f87fd View commit details
  3. Release v1.3.1 (#1816)

    messense authored Oct 24, 2023
    Copy the full SHA
    879bc88 View commit details
36 changes: 22 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -67,11 +67,11 @@ jobs:
- macos-13
- windows-latest
PYTHON_VERSION: |
- '3.7'
- '3.8'
- '3.9'
- '3.10'
- '3.11'
- '3.12'
- 'pypy3.9'
- 'pypy3.10'
@@ -108,6 +108,13 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
architecture: "x64"
- name: Set PYTHON_VERSION env var
shell: bash
run: |
set -ex
# remove -dev suffix
python_version=$(echo ${{ matrix.python-version }} | sed -e s/-dev//)
echo "PYTHON_VERSION=$python_version" >> "${GITHUB_ENV}"
- name: Install cffi
if: ${{ !contains(matrix.python-version, 'pypy') }}
run: pip install cffi
@@ -136,7 +143,7 @@ jobs:
# Caching
# Install gnu-tar because BSD tar is buggy
# https://github.com/actions/cache/issues/403
- name: Install GNU tar (Macos)
- name: Install GNU tar (macOS)
if: startsWith(matrix.os, 'macos')
run: |
brew install gnu-tar
@@ -152,6 +159,7 @@ jobs:
- name: cargo test
run: cargo nextest run --features password-storage
- name: test cross compiling with zig
if: ${{ !contains(matrix.python-version, '-dev') }}
shell: bash
run: |
set -ex
@@ -160,13 +168,13 @@ jobs:
rustup target add aarch64-apple-darwin
# abi3
cargo run -- build -i ${{ matrix.python-version }} -m test-crates/pyo3-pure/Cargo.toml --target aarch64-unknown-linux-gnu --zig
cargo run -- build -i ${{ matrix.python-version }} -m test-crates/pyo3-pure/Cargo.toml --target aarch64-unknown-linux-musl --zig
if [[ "${{ matrix.python-version }}" != "pypy"* ]]; then
cargo run -- build -i ${{ matrix.python-version }} -m test-crates/pyo3-pure/Cargo.toml --target aarch64-apple-darwin --zig
cargo run -- build -i $PYTHON_VERSION -m test-crates/pyo3-pure/Cargo.toml --target aarch64-unknown-linux-gnu --zig
cargo run -- build -i $PYTHON_VERSION -m test-crates/pyo3-pure/Cargo.toml --target aarch64-unknown-linux-musl --zig
if [[ "$PYTHON_VERSION" != "pypy"* ]]; then
cargo run -- build -i $PYTHON_VERSION -m test-crates/pyo3-pure/Cargo.toml --target aarch64-apple-darwin --zig
fi
if [[ "${{ matrix.python-version }}" == "3.1"* ]]; then
if [[ "$PYTHON_VERSION" == "3.1"* ]]; then
# Check abi3 wheels with abi3audit on CPython only
pip install abi3audit
abi3audit test-crates/pyo3-pure/target/wheels/*.whl
@@ -175,14 +183,14 @@ jobs:
twine check --strict test-crates/pyo3-pure/target/wheels/*.whl
# non-abi3
cargo run -- build -i ${{ matrix.python-version }} -m test-crates/pyo3-mixed/Cargo.toml --target aarch64-unknown-linux-gnu --zig
if [[ "${{ matrix.python-version }}" != "pypy"* ]]; then
cargo run -- build -i ${{ matrix.python-version }} -m test-crates/pyo3-mixed/Cargo.toml --target aarch64-apple-darwin --zig
cargo run -- build -i $PYTHON_VERSION -m test-crates/pyo3-mixed/Cargo.toml --target aarch64-unknown-linux-gnu --zig
if [[ "$PYTHON_VERSION" != "pypy"* ]]; then
cargo run -- build -i $PYTHON_VERSION -m test-crates/pyo3-mixed/Cargo.toml --target aarch64-apple-darwin --zig
fi
# Check wheels with twine
twine check --strict test-crates/pyo3-mixed/target/wheels/*.whl
- name: test cross compiling windows wheel
if: ${{ matrix.os == 'ubuntu-latest' && !contains(matrix.python-version, 'pypy') }}
if: ${{ matrix.os == 'ubuntu-latest' && !contains(matrix.python-version, 'pypy') && !contains(matrix.python-version, '-dev') }}
run: |
set -ex
sudo apt-get install -y mingw-w64
@@ -195,7 +203,7 @@ jobs:
cargo run -- build -m test-crates/pyo3-pure/Cargo.toml --target x86_64-pc-windows-msvc
# no-abi3
cargo run -- build -i python${{ matrix.python-version }} -m test-crates/pyo3-mixed/Cargo.toml --target x86_64-pc-windows-msvc
cargo run -- build -i "python${PYTHON_VERSION}" -m test-crates/pyo3-mixed/Cargo.toml --target x86_64-pc-windows-msvc
- name: test compiling with PYO3_CONFIG_FILE
shell: bash
run: |
@@ -348,8 +356,8 @@ jobs:
platform:
# CPython
- target: aarch64-unknown-linux-gnu
abi: cp37-cp37m
python: python3.7
abi: cp38-cp38
python: python3.8
container: ghcr.io/rust-cross/manylinux2014-cross:aarch64
- target: armv7-unknown-linux-gnueabihf
abi: cp39-cp39
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@ repos:
types: [rust]
stages: [manual] # because it's slow
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-yaml
- id: check-toml
@@ -56,20 +56,20 @@ repos:
)
- id: mixed-line-ending
- repo: https://github.com/psf/black
rev: 23.9.1
rev: 23.10.0
hooks:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.291
rev: v0.1.1
hooks:
- id: ruff
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.5.1
rev: v1.6.1
hooks:
- id: mypy
entry: mypy maturin/
pass_filenames: false
- repo: https://github.com/codespell-project/codespell
rev: v2.2.5
rev: v2.2.6
hooks:
- id: codespell
14 changes: 7 additions & 7 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
authors = ["konstin <konstin@mailbox.org>", "messense <messense@icloud.com>"]
name = "maturin"
version = "1.3.0"
version = "1.3.1"
description = "Build and publish crates with pyo3, rust-cpython and cffi bindings as well as rust binaries as python packages"
exclude = [
"test-crates/**/*",
@@ -90,7 +90,7 @@ tracing-subscriber = { version = "0.3.15", features = ["env-filter"], optional =
# project scaffolding, maturin new/init/generate-ci
dialoguer = { version = "0.10.2", default-features = false, optional = true }
console = { version = "0.15.4", optional = true }
minijinja = { version = "1.0.0", optional = true }
minijinja = { version = "1.0.7", optional = true }

# upload
bytesize = { version = "1.0.1", optional = true }
12 changes: 11 additions & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
@@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.3.1] - 2023-10-24

* Use external `uniffi-bindgen` if no root package is configured in [#1797](https://github.com/PyO3/maturin/pull/1797)
* Fix wheel filename for GraalPy in [#1802](https://github.com/PyO3/maturin/pull/1802)
* Add unittest skeleton to mixed Python/Rust projects in [#1807](https://github.com/PyO3/maturin/pull/1807)
* Preserve trailing whitespace in new project files in [#1808](https://github.com/PyO3/maturin/pull/1808)
* Fix missing `workspace.members` in sdist in [#1811](https://github.com/PyO3/maturin/pull/1811)
* Don't set `MACOSX_DEPLOYMENT_TARGET` for editable builds by default in [#1815](https://github.com/PyO3/maturin/pull/1815)

## [1.3.0] - 2023-10-02

* Refactor Cargo sdist generator to avoid rewriting local dependencies in [#1741](https://github.com/PyO3/maturin/pull/1741)
@@ -918,7 +927,8 @@ points-0.1.0-py2.py3-none-manylinux1_x86_64.whl | 2,8M | 752K | 85K

* Initial Release

[Unreleased]: https://github.com/pyo3/maturin/compare/v1.3.0...HEAD
[Unreleased]: https://github.com/pyo3/maturin/compare/v1.3.1...HEAD
[1.3.1]: https://github.com/pyo3/maturin/compare/v1.3.0...v1.3.1
[1.3.0]: https://github.com/pyo3/maturin/compare/v1.2.3...v1.3.0
[1.2.3]: https://github.com/pyo3/maturin/compare/v1.2.2...v1.2.3
[1.2.2]: https://github.com/pyo3/maturin/compare/v1.2.1...v1.2.2
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -39,17 +39,17 @@ FROM base-$TARGETARCH

ENV PATH /root/.cargo/bin:$PATH
# Add all supported python versions
ENV PATH /opt/python/cp37-cp37m/bin:/opt/python/cp38-cp38/bin:/opt/python/cp39-cp39/bin:/opt/python/cp310-cp310/bin:/opt/python/cp311-cp311/bin:$PATH
ENV PATH /opt/python/cp38-cp38/bin:/opt/python/cp39-cp39/bin:/opt/python/cp310-cp310/bin:/opt/python/cp311-cp311/bin:/opt/python/cp312-cp312/bin:$PATH
# Otherwise `cargo new` errors
ENV USER root

RUN curl --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \
&& yum install -y libffi-devel openssh-clients \
&& python3.7 -m pip install --no-cache-dir cffi \
&& python3.8 -m pip install --no-cache-dir cffi \
&& python3.9 -m pip install --no-cache-dir cffi \
&& python3.10 -m pip install --no-cache-dir cffi \
&& python3.11 -m pip install --no-cache-dir cffi \
&& python3.12 -m pip install --no-cache-dir cffi \
&& mkdir /io

COPY --from=builder /usr/bin/maturin /usr/bin/maturin
10 changes: 10 additions & 0 deletions guide/src/distribution.md
Original file line number Diff line number Diff line change
@@ -289,3 +289,13 @@ Options:
-h, --help
Print help information (use `-h` for a summary)
```

### Using PyPI's trusted publishing

By default, the workflow provided by `generate-ci` will publish the release artifacts to PyPI using API token authentication. However, maturin also supports [trusted publishing (OpenID Connect)](https://docs.pypi.org/trusted-publishers/).

To enable it, modify the `release` action in the generated GitHub workflow file:
- remove `MATURIN_PYPI_TOKEN` from the `env` section to make maturin use trusted publishing
- add `id-token: write` to the action's `permissions` (see [Configuring OpenID Connect in PyPI](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-pypi) from GitHub's documentation).

Make sure to follow the steps listed in [PyPI's documentation](https://docs.pypi.org/trusted-publishers/adding-a-publisher/) to set up your GitHub repository as a trusted publisher in the PyPI project settings before attempting to run the workflow.
2 changes: 1 addition & 1 deletion guide/src/platform_support.md
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ supported by [manylinux](https://github.com/pypa/manylinux).

## Python Support

CPython 3.7 to 3.10 are supported and tested on CI, though the entire 3.x series should work.
CPython 3.8 to 3.10 are supported and tested on CI, though the entire 3.x series should work.
This will be changed as new python versions are released and others have their end of life.

PyPy 3.6 and later also works, as does GraalPy 23.0 and later.
14 changes: 7 additions & 7 deletions guide/src/tutorial.md
Original file line number Diff line number Diff line change
@@ -36,8 +36,8 @@ crate-type = ["cdylib"]
rand = "0.8.4"

[dependencies.pyo3]
version = "0.18.0"
# "abi3-py37" tells pyo3 (and maturin) to build using the stable ABI with minimum Python version 3.7
version = "0.19.0"
# "abi3-py38" tells pyo3 (and maturin) to build using the stable ABI with minimum Python version 3.8
features = ["abi3-py37"]
```

@@ -76,7 +76,7 @@ Options:
```

The above process can be achieved by running `maturin new -b pyo3 guessing_game`
then edit `Cargo.toml` to add `abi3-py37` feature.
then edit `Cargo.toml` to add `abi3-py38` feature.

## Install and configure maturin (in a virtual environment)

@@ -88,7 +88,7 @@ ferris@rustbox [~/src/rust/guessing-game] % python3 -m venv .venv
ferris@rustbox [~/src/rust/guessing-game] % source .venv/bin/activate
(.venv) ferris@rustbox [~/src/rust/guessing-game] % pip install -U pip maturin
(.venv) ferris@rustbox [~/src/rust/guessing-game] % pip freeze
maturin==0.14.0
maturin==1.3.0
tomli==2.0.1
```

@@ -200,7 +200,7 @@ So let's use maturin to build and install in our current environment.

```shell
(.venv) ferris@rustbox [~/src/rust/guessing-game] % maturin develop
🔗 Found pyo3 bindings with abi3 support for Python ≥ 3.7
🔗 Found pyo3 bindings with abi3 support for Python ≥ 3.8
🐍 Not using a specific python interpreter (With abi3, an interpreter is only required on windows)
Compiling pyo3-build-config v0.18.0
Compiling libc v0.2.119
@@ -276,10 +276,10 @@ wheels compatible with a wide range of Linux distros.

```shell
(.venv) ferris@rustbox [~/src/rust/guessing-game] % maturin build
🔗 Found pyo3 bindings with abi3 support for Python ≥ 3.7
🔗 Found pyo3 bindings with abi3 support for Python ≥ 3.8
🐍 Not using a specific python interpreter (With abi3, an interpreter is only required on windows)
Finished dev [unoptimized + debuginfo] target(s) in 7.32s
📦 Built wheel for abi3 Python ≥ 3.7 to /Users/ferris/src/rust/guessing-game/target/wheels/guessing_game-0.1.0-cp37-abi3-macosx_10_7_x86_64.whl
📦 Built wheel for abi3 Python ≥ 3.8 to /Users/ferris/src/rust/guessing-game/target/wheels/guessing_game-0.1.0-cp37-abi3-macosx_10_7_x86_64.whl
```

maturin can even publish wheels directly to [PyPI](https://pypi.org) with
2 changes: 1 addition & 1 deletion src/auditwheel/audit.rs
Original file line number Diff line number Diff line change
@@ -50,7 +50,7 @@ pub enum AuditWheelError {
/// libraries with blacked-list symbols.
#[error("Your library is not {0} compliant because it depends on black-listed symbols: {1:?}")]
BlackListedSymbolsError(Policy, Vec<String>),
/// The elf file isn't manylinux/musllinux compaible. Contains unsupported architecture
/// The elf file isn't manylinux/musllinux compatible. Contains unsupported architecture
#[error("Your library is not {0} compliant because it has unsupported architecture: {1}")]
UnsupportedArchitecture(Policy, String),
/// This platform tag isn't defined by auditwheel yet
4 changes: 2 additions & 2 deletions src/compile.rs
Original file line number Diff line number Diff line change
@@ -419,8 +419,8 @@ fn compile_target(
build_command.env("PYO3_CROSS_LIB_DIR", lib_dir);
}

// Set default macOS deployment target version
if target.is_macos() && env::var_os("MACOSX_DEPLOYMENT_TARGET").is_none() {
// Set default macOS deployment target version for non-editable builds
if !context.editable && target.is_macos() && env::var_os("MACOSX_DEPLOYMENT_TARGET").is_none() {
use crate::build_context::rustc_macosx_target_version;

let target_config = context
11 changes: 7 additions & 4 deletions src/module_writer.rs
Original file line number Diff line number Diff line change
@@ -872,11 +872,14 @@ fn uniffi_bindgen_command(crate_dir: &Path) -> Result<Command> {
.no_deps()
.verbose(true)
.exec()?;
let root_pkg = cargo_metadata.root_package().unwrap();
let root_pkg = cargo_metadata.root_package();
let has_uniffi_bindgen_target = root_pkg
.targets
.iter()
.any(|target| target.name == "uniffi-bindgen" && target.is_bin());
.map(|pkg| {
pkg.targets
.iter()
.any(|target| target.name == "uniffi-bindgen" && target.is_bin())
})
.unwrap_or(false);
let command = if has_uniffi_bindgen_target {
let mut command = Command::new("cargo");
command.args(["run", "--bin", "uniffi-bindgen", "--manifest-path"]);
6 changes: 6 additions & 0 deletions src/new_project.rs
Original file line number Diff line number Diff line change
@@ -33,6 +33,7 @@ impl<'a> ProjectGenerator<'a> {
) -> Result<Self> {
let crate_name = project_name.replace('-', "_");
let mut env = Environment::new();
env.set_keep_trailing_newline(true);
env.add_template(".gitignore", include_str!("templates/.gitignore.j2"))?;
env.add_template("Cargo.toml", include_str!("templates/Cargo.toml.j2"))?;
env.add_template(
@@ -43,6 +44,7 @@ impl<'a> ProjectGenerator<'a> {
env.add_template("main.rs", include_str!("templates/main.rs.j2"))?;
env.add_template("build.rs", include_str!("templates/build.rs.j2"))?;
env.add_template("__init__.py", include_str!("templates/__init__.py.j2"))?;
env.add_template("test_all.py", include_str!("templates/test_all.py.j2"))?;
env.add_template("example.udl", include_str!("templates/example.udl.j2"))?;

let bridge_model = match bindings.as_str() {
@@ -86,6 +88,10 @@ impl<'a> ProjectGenerator<'a> {
fs::create_dir_all(&python_project)?;
self.write_project_file(&python_project, "__init__.py")?;

let test_dir = python_dir.join("tests");
fs::create_dir_all(&test_dir)?;
self.write_project_file(&test_dir, "test_all.py")?;

if src {
project_path.join("rust")
} else {
Loading