-
Notifications
You must be signed in to change notification settings - Fork 76
Add python devShell to nix flake #864
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -93,6 +93,52 @@ | |
| "payjoin-directory" = ""; | ||
| }; | ||
|
|
||
| # Python-specific configuration | ||
| pythonVersion = pkgs.python3; | ||
| pythonEnv = pythonVersion.withPackages (ps: with ps; [ | ||
| virtualenv | ||
| pip | ||
| ]); | ||
|
|
||
| # Determine platform for generate script | ||
| supportedPlatforms = { | ||
| "x86_64-linux" = "linux"; | ||
| "aarch64-linux" = "linux"; | ||
| "x86_64-darwin" = "macos"; | ||
| "aarch64-darwin" = "macos"; | ||
| }; | ||
| platform = supportedPlatforms.${system} or (throw "Unsupported platform: ${system}. Supported platforms: ${builtins.concatStringsSep ", " (builtins.attrNames supportedPlatforms)}"); | ||
|
|
||
| # Python devShell | ||
| pythonDevShell = pkgs.mkShell { | ||
| name = "python-dev"; | ||
| buildInputs = with pkgs; [ | ||
| pythonEnv | ||
| bash | ||
| ]; | ||
|
|
||
| # Environment variables and shell hook | ||
| shellHook = '' | ||
| export LD_LIBRARY_PATH=${pkgs.lib.makeLibraryPath [pkgs.openssl]}:$LD_LIBRARY_PATH | ||
| cd payjoin-ffi/python | ||
| # Create and activate virtual environment | ||
| python -m venv venv | ||
| source venv/bin/activate | ||
| # Install dependencies, allowing PyPI fetches for version mismatches | ||
| pip install --requirement requirements.txt --requirement requirements-dev.txt | ||
| # Generate bindings, setting PYBIN to the venv's python binary | ||
| export PYBIN=./venv/bin/python | ||
| bash ./scripts/generate_${platform}.sh | ||
| # Set CARGO_TOML_PATH for setup.py | ||
| export CARGO_TOML_PATH=${./.}/Cargo.toml | ||
| # Build the wheel | ||
| python setup.py bdist_wheel --verbose | ||
|
|
||
| # Install payjoin | ||
| pip install ./dist/payjoin-*.whl | ||
|
Comment on lines
+122
to
+138
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. any chance we can use uv and uv2nix instead of pip? requirements.txt is not reproducible, and poetry2nix is kinda dead these days doing this in a shell hook also means we can't really use this in a flake check in a clean way, so while this is convenient it seems like it would be pretty brittle in the long term and if people run into problems we would have a hard time debugging without a lot of manual intervention especially because |
||
| ''; | ||
| }; | ||
|
|
||
| devShells = builtins.mapAttrs (_name: craneLib: | ||
| craneLib.devShell { | ||
| packages = with pkgs; [ | ||
|
|
@@ -115,7 +161,10 @@ | |
| // args); | ||
| in { | ||
| packages = packages; | ||
| devShells = devShells // {default = devShells.nightly;}; | ||
| devShells = devShells // { | ||
| default = devShells.nightly; | ||
| python = pythonDevShell; | ||
| }; | ||
| formatter = pkgs.alejandra; | ||
| checks = | ||
| packages | ||
|
|
||
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.
wouldn't using
${system}potentially be more future proof? they can still be a single file using symlinks but if there are any platform specific quirks down the line i suspect the net result would be adding another layer on top of this, instead of going the more direct route