Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider pyproject.toml features when detecting pyo3 #1014

Merged
merged 1 commit into from
Jul 19, 2022

Conversation

daniestevez
Copy link

We have a mixed python/Rust project which uses PyO3. PyO3 is declared as an optional dependency of our crate, which gets enabled with a feature python. This allows us to build the crate as a Rust-only library as well.

Starting with maturin 0.13.0 (and also in the master branch), we have noticed that maturin does no longer detect pyo3, so it tries to use CFFI bindings rather than pyo3 bindings. With maturin <0.13 we were using cargo-extra-args in pyproject.toml, and with maturin >=0.13 we have switched this to features (also in pyproject.toml).

This repository demonstrates this.

Looking at the code, we think that the problem is that the features enabled in pyproject.toml are not merged when obtaining the cargo metadata to produce the dependency graph.

@netlify
Copy link

netlify bot commented Jul 19, 2022

Deploy Preview for maturin-guide ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 71f7825
🔍 Latest deploy log https://app.netlify.com/sites/maturin-guide/deploys/62d65cf12a1a09000843eb22
😎 Deploy Preview https://deploy-preview-1014--maturin-guide.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@messense
Copy link
Member

Thanks! Please add a changelog entry.

Consider the cargo options merged from the pyproject.toml when
generating the cargo metadata.

This fixes the following problem: if pyo3 is an optional dependency
that is enabled through a feature declared in pyproject.toml, then
maturin will not detect pyo3 as binding.
@daniestevez
Copy link
Author

Thank you for your fast response. I've force-pushed to include the changelog entry.

Copy link
Member

@messense messense left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@messense messense merged commit 0d9d09d into PyO3:main Jul 19, 2022
bmwiedemann pushed a commit to bmwiedemann/openSUSE that referenced this pull request Aug 8, 2022
https://build.opensuse.org/request/show/991319
by user mia + dimstar_suse
- Update to v0.13.1
  * Add 64-bit RISC-V support
    gh#PyO3/maturin#1001
  * Run tests on CI with cargo-nextest
    gh#PyO3/maturin#1004
  * Add support for invoking with python3 -m maturin
    gh#PyO3/maturin#1008
  * Consider pyproject.toml features when detecting pyo3
    gh#PyO3/maturin#1014
  * Respect user specified Rust target in maturin develop
    gh#PyO3/maturin#1016
  * Use cargo rustc --crate-type cdylib on Rust nightly/dev channel
    gh#PyO3/maturin#1020
  * Use cargo-nextest in test-alpine
    gh#PyO3/maturin#1021
-  Update to v0.13.0
  * Drop python 3.6 by @konstin in #945
  * Add support for building with multiple binary targets by
    @messense in #948
  * Add a --target option to maturin list-python command by
    @messense in #957
  * Add support for using bundled pyth
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants