Skip to content

Introspection: add a CLI to generate stubs#5904

Open
Tpt wants to merge 5 commits intoPyO3:mainfrom
Tpt:tpt/introspection-bin
Open

Introspection: add a CLI to generate stubs#5904
Tpt wants to merge 5 commits intoPyO3:mainfrom
Tpt:tpt/introspection-bin

Conversation

@Tpt
Copy link
Copy Markdown
Contributor

@Tpt Tpt commented Mar 23, 2026

Useful for setuptools-rust

Use it also for the integration tests

@Tpt Tpt force-pushed the tpt/introspection-bin branch 2 times, most recently from 70f0bd1 to b5efccb Compare March 23, 2026 09:55
@Tpt Tpt marked this pull request as ready for review March 23, 2026 10:19
@Tpt Tpt force-pushed the tpt/introspection-bin branch from bc46553 to 27af589 Compare March 25, 2026 18:14
@davidhewitt
Copy link
Copy Markdown
Member

Thanks, the binary implementation looks fine to me (and matches what I've done locally in testing previously).

Some thoughts / questions:

  • Will we ship prebuilt versions of this, e.g. on this repository? If no, will setuptools-rust build it from scratch?
  • Does this affect any planned integration with maturin (e.g. make it irrelevant?)
  • Should we document how to use this in type-stub.md?

@Tpt
Copy link
Copy Markdown
Contributor Author

Tpt commented Mar 31, 2026

Will we ship prebuilt versions of this, e.g. on this repository? If no, will setuptools-rust build it from scratch?

Good question. Building in this repository and publish on pypi is likely the easiest and nicest way to go. This way setuptools-rust can just depend on it. Glad to do the basic setup if you are ok with this idea.

Does this affect any planned integration with maturin (e.g. make it irrelevant?)

No, maturin integration is imho still very relevant as an "integrated" tool doing everything (build + introspection). We just merged PyO3/maturin#3105 with first integration bit (a --generate-stubs option that adds stubs to the built artifacts).

Should we document how to use this in type-stub.md?

Definitely. Done. I have also added some documentation for the new maturin features.

@Tpt
Copy link
Copy Markdown
Contributor Author

Tpt commented Apr 29, 2026

@davidhewitt just a small up to make sure you have seen my answers. Sorry for that

Tpt added 2 commits April 29, 2026 15:54
Useful for setuptools-rust

Use it also for the integration tests
@Tpt Tpt force-pushed the tpt/introspection-bin branch from 27af589 to 4ee4fab Compare April 29, 2026 13:59
@Tpt Tpt force-pushed the tpt/introspection-bin branch from 4ee4fab to c697543 Compare April 29, 2026 14:04
Copy link
Copy Markdown
Member

@davidhewitt davidhewitt left a comment

Choose a reason for hiding this comment

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

Makes sense, I think we can indeed ship on PyPI with the same version numbering we use for the rest of PyO3?

@davidhewitt
Copy link
Copy Markdown
Member

(That can be a follow-up, I guess)

@davidhewitt davidhewitt mentioned this pull request Apr 30, 2026
@Tpt Tpt force-pushed the tpt/introspection-bin branch from 26abbc6 to de92476 Compare April 30, 2026 15:40
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 30, 2026

Merging this PR will improve performance by 13.8%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
✅ 104 untouched benchmarks
⏩ 1 skipped benchmark1

Performance Changes

Benchmark BASE HEAD Efficiency
bench_pyclass_create 4.6 µs 4 µs +13.8%

Comparing Tpt:tpt/introspection-bin (9583119) with main (cf4d883)

Open in CodSpeed

Footnotes

  1. 1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports.

@Tpt Tpt force-pushed the tpt/introspection-bin branch from de92476 to 2897f00 Compare April 30, 2026 18:32
Comment thread .github/workflows/python-wheel.yml Outdated
@Tpt
Copy link
Copy Markdown
Contributor Author

Tpt commented Apr 30, 2026

Makes sense, I think we can indeed ship on PyPI with the same version numbering we use for the rest of PyO3?

@davidhewitt Done. I have written the publishing action and setup a "pending publisher" on Pypi. When the next release is done I can share the package with you.

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.

3 participants