Skip to content

Conversation

@davidhewitt
Copy link
Member

Following up from #5343

This updates documentation across the codebase to discourage use of the extension-module feature and to instead rely on the PYO3_BUILD_EXTENSION_MODULE environment variable when relevant.

Comment on lines 74 to 76
PyO3 has some Cargo features to configure projects for building Python extension modules:

- The `extension-module` feature, which must be enabled when building Python extension modules.
- The `PYO3_BUILD_EXTENSION_MODULE` environment variable, which must be set when building Python extension modules.
Copy link
Contributor

Choose a reason for hiding this comment

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

The bullet doesn't match the intro :-)

It's probably worth saying that people don't generally need to set this themselves, because maturin/setuptools-rust set it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, done in 7e8882e and 2e65a8f

Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com>
@davidhewitt davidhewitt enabled auto-merge November 8, 2025 18:04
@davidhewitt davidhewitt added this pull request to the merge queue Nov 8, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 8, 2025
@davidhewitt
Copy link
Member Author

Looks like this failed to merge because ffi-check is linking when it doesn't need to; I'll try to rework that as a separate step first.

@davidhewitt
Copy link
Member Author

I think we can review/merge #5624 and then this PR should be mergeable.

Copy link
Contributor

@MatthijsKok MatthijsKok left a comment

Choose a reason for hiding this comment

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

With #5624 merged, is this now mergeable?

I've read the updated guide text and I think its clear and consistent.
Thanks for the work that you do :)

Comment on lines +196 to +198
### The `PYO3_BUILD_EXTENSION_MODULE` environment variable

PyO3's `extension-module` feature is used to disable [linking](https://en.wikipedia.org/wiki/Linker_(computing)) to `libpython` on Unix targets.
<a name="the-extension-module-feature"></a> <!-- for backwards compatibility -->
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion:
Could also use a heading attribute here now, like here in the mdbook0.5 upgrade.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think I want both the new heading referring to the environment variable, and the old one referring to the feature.

@davidhewitt davidhewitt added this pull request to the merge queue Nov 30, 2025
Merged via the queue into PyO3:main with commit 58ba6dc Nov 30, 2025
43 checks passed
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.

4 participants