feat: added Python stub auto-generation with pyo3-introspection#54
Conversation
There was a problem hiding this comment.
not sure if ready for review, so just some quick comments.
These types get automatically picked up by new pypi packages right? So no need to add extra instructions to the python section of the root-level readme?
(Although tbh I'm not sure how much my review will be worth anyway. If you test that it works that's probably sufficient.)
(also, feel free to contact me on discord; your collegues know my handle :) )
|
clarification: the stub regeneration instructions I added to Yes, the types should get picked up automatically by new PyPI packages. I'll test to make sure that works now. ✅ However, I also added a Python stub-regeneration check to CI to ensure they're kept up to date and working correctly. In order to do this check, the auto-generated What I could do is modify the CI check to verify that the command succeeds but not check the output. Then we could remove the stub regeneration instructions. The only potential issue would be if the stub regeneration returns with a success code but doesn't generate the expected stubs, which may be unlikely enough that you'd prefer the simpler workflow. We'd need to modify the PyPI release script as well to regenerate the |
|
Ah right, if you can move the generation into the pypi release workflow, that does sound less intrusive for day-to-day development. (That is what you're suggesting right?) And then they don't have to be committed at all, but we could indeed test that generating them does succeed. |
|
Since you're already working on the python side: Any ideas on how to also ship bindings for the AVX-512 side of things? This post has some options:
Do you think shipping eg For the main binary release I'm going to use cargo-multivers which compiles the two versions of the binary into a single output, but I don't think this will work for libraries. |
9f81601 to
2bdf23a
Compare
|
I haven't worked with shipping bindings for multiple SIMD targets before, but I did just come across |
|
As far as I understand it, that crate will not work for us. I think it tells the compiler to auto-vectorize a given function separately for each target architecture, but we want to manually write specific SIMD-intrinsics. We also use |
33a35a2 to
f4bf360
Compare
f4bf360 to
1d3e698
Compare
Yes! I moved the stub generation into the PyPI release workflow and kept the test.
I don't love any of the options above, but I think you're right. Shipping both |
|
Then the question is if we ship 1 package with sassy and sassy_512 libs, or 2 packages with sassy as lib. Probably the former, and then we can do |
|
otherwise the python-stub code lgtm on a not-very-close look. If you're happy to merge then so am I :) |
| - name: Generate stubs | ||
| run: | | ||
| RUSTFLAGS="${{ matrix.stub_rustflags }}" cargo build --features python | ||
| cargo run --features python-stubs --bin gen_stubs -- target/debug/${{ matrix.lib_name }} |
There was a problem hiding this comment.
sgtm.
But do we need uv for this? Ugh installing things in these CI containers is such a mess and I never have any idea if caching works or not for this. But maybe they already have mypy and just mypy path/... works?
There was a problem hiding this comment.
That sounds reasonable too! Mostly, I know the uv approach works with a cache.
There was a problem hiding this comment.
Then in should be fine :)
There was a problem hiding this comment.
I added in the cached uv, and set the Python version of the stub checks to 3.9 (3.8 doesn't support list type annotations used in the example_typed.py).
|
ready for merge then? |
|
Yes, this should be ready to merge. |
3455c88
into
RagnarGrootKoerkamp:master
No description provided.