-
Notifications
You must be signed in to change notification settings - Fork 418
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
python: script to build python package #702
Conversation
This is a quick POC to build the python script, it seems to work. The only problem I see is that the version number of the python package is taken from the rust package, and not from the python one:
This is a problem as python packages have their own versions on pypi and we need to keep them separate. @ia0 thoughts? |
Interesting, this is PyO3/maturin#2163 and I don't see any good workaround. What we could do is hard-code the |
I guess that ugly is better that nothing for the time being? :-) Instead of hardcoding the version, we could also patch the appropriate rust files as part of the build script? To make things worse, the version of the python package is computed at run time ( Anyways, it would be nice to contain all the ugly parts in a specific place, and to keep as much as possible clean. So we could aim at keeping the codebase clean, and stashing all the bad stuff in a build script. Now, if we go forward with something like this, is it clear to you how would the full build / publish package look like? Things were much simpler in the past: I would build the package on my machine, and then publish it myself to pypi. Now, with the multiarch support for the rust binary, I guess the plan is to use gh actions to build the various versions of the package; gh actions would then produce some artifacts; and then? do we already know what's the well-lit path to publish the various wheels? /cc @invernizzi |
The problem of using a hack is that it needs to work on Windows too, so it probably needs to be a Rust (or Python) program and not a shell script. But otherwise, I think it's possible to do the following:
|
Do we need this because we need to compile the rust binary for a windows env as well? I thought the complications were due to the different architectures (x86, arm, etc.), rather than OS? Anyways, I'll rewrite it in python, it's not a super trivial script anymore. |
Yes, but that's not enough to explain why the script needs to work on Windows, because we could cross-compile. The reason we don't cross-compile is because of Maturin (I expect the |
Makes sense 👍 working on the python version now. |
Almost done, two questions in the meantime:
|
12125a8
to
ab299d5
Compare
No, it's the script. You essentially need to change this line: Line 64 in 5f07dd1
to something like this (where the version is taken from let binary = "0.1.0-rc.0-dev"; Feel free to change the initial line to prevent modifications: let binary = clap::crate_version!(); // keep in sync with python build script
It should be enough to run |
ce68a4a
to
47ae512
Compare
Success! Now the resulting python package has the correct version, and the magika rust binary has its own (correct) version as well. I'll wait for your quick review before merging, thanks! |
47ae512
to
32f77c3
Compare
This implements a script to build the python package. While in theory this would just be
uv build
, we are hitting a number of problems / corner cases with maturin. This script implements a temporary solution to workaround all existing problems; we'll clean up as soon as the underlying tooling gets better.Closes #566.