-
Notifications
You must be signed in to change notification settings - Fork 76
Replace pip with uv in payjoin-ffi/python
#1073
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
Conversation
9dbf217 to
3aa110f
Compare
Pull Request Test Coverage Report for Build 18009273643Details
💛 - Coveralls |
`uv` has significant speed, dependency management, and virtual environment advantages compared to `pip`, in addition to being backward compatible with `pip`. This commit replaces `pip` with `uv` everywhere it is used in our python FFI bindings and updates the README with the simplified uv- specific instructions.
| enable-cache: true | ||
|
|
||
| - name: "uv sync" | ||
| run: uv sync --all-extras |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This command includes all "optional" (i.e. dev) dependencies and is the replacement for pip install but also updates the .venv and lockfile
| - name: Install a specific version of uv | ||
| uses: astral-sh/setup-uv@v6 | ||
| with: | ||
| version: "0.8.2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is simply the current version of uv, I figured we shouldn't just arbitrarily pull latest?
|
|
||
| - name: "Build wheel" | ||
| run: python -m build --wheel | ||
| run: uv build --wheel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running just uv build would have built both the source and binary (wheel) distribution, which is redundant so we only build the binary here.
| *.whl | ||
| build/ | ||
| venv | ||
| .venv |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uv's virtualenv lives in .venv
818b7db to
3bbb35c
Compare
| git clone https://github.com/payjoin/rust-payjoin.git | ||
| cd rust-payjoin/payjoin-ffi/python |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seemed redundant
| # Ensure you have uv installed: | ||
| # https://docs.astral.sh/uv/getting-started/installation/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are, of course, other deps required (gcc compiler, for ex.) but these will be abstracted away in uv2nix in the next PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in a separate followup PR it'd make sense to add python and these toolchain bits to the devshell
not sure it should be gcc though, since rustc uses llvm clang might be the more appropriate option
nothingmuch
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK, afaict this is basically the same as what we came up with before
this should be reviewed by someone else too since i co-authored these changes
@benalleng perhaps? |
spacebear21
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tACK 3bbb35c, tested the new "generate python bindings and run tests" on macOS with no issues after installing uv.
Sidenote, it would be nice to move the "build and reinstall wheel" steps into the generate_bindings.sh script if at all possible to reduce the number of commands to run.
I think that should be done in a separate script (a test.sh?) or just a flake check (in which case it'd be |
Pull Request Checklist
Please confirm the following before requesting review:
AI
in the body of this PR.
This continues the work done in by @nothingmuch in #997. When we first started creating nix
devShellsin #864, @nothingmuch pointed out that we lose many of the reproducibility benefits of Nix by usingpipwithout a lockfile.pipcan create lockfiles but the process is very manual and verbose, aside from the many other benefitsuvbrings us, such as:venv)Also noted by @nothingmuch here.
By making this change we will also be able to use
uv2nixin a subsequent PR to have Nix auto-generate adevShellor perform the tests with a simplenix flake checkcommand.Note that this PR does not yet modify anything with the Nix devShells yet, just replaces
pipwithuv. When we do combine this with nix, we will have complete dependency management for users who have nix installed.I did run into one hiccup with the dependencies in
generate_bindings.sh. There are "debianisms" see commit which make this impossible to run on many Linux systems. Basically it installs two dependencies required for building:build-essentialandpython3-dev. I removed those install lines and instead them as a comment in the README to ensure the user had these before running the script. In one way this makes it less robust for users who don't already have those, but it decouples the script from the Linux distro and also paves the way for us to add these dependencies in our nix flake later.You should just be able to follow the updated instructions in the README and generating the bindings, building, and the tests should work.
To create a shell environment with the necessary dependencies installed for testing this PR, I used the below
shell.nixwith the required dependencies: