-
Notifications
You must be signed in to change notification settings - Fork 93
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 bindings #1036
Python bindings #1036
Conversation
a454f9a
to
b42a911
Compare
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.
LGMT overall 👍
The CI is failing, presumably because now building the dependencies of the workspace implies to build pyo3
which requires python. I guess it's fine to do so in the checks, but not when just building e.g. Nickel.
But that may not be totally straightforward to achieve right now, not because of any Nix or Crane limitations, but because of how the flake is organized. It seems we always builds the dependencies of the whole workspace before anything else.
Trying to fix the error from the CI here: https://github.com/tweag/nickel/actions/runs/3876173138/jobs/6609682802
I can fix this issue with a patch on diff --git a/flake.nix b/flake.nix
index 1c6fd331..580368cc 100644
--- a/flake.nix
+++ b/flake.nix
@@ -196,6 +196,7 @@
inherit
src
cargoExtraArgs;
+ buildInputs = [ pkgs.python3 ];
};
nickel = craneLib.buildPackage { but then building the
|
I think I fixed the Nix build. I removed Note that there is no derivation for the Python bindings (pyckel) since I have not yet managed to make it work. I suggest to tackle that in another PR. |
I've requested reviews from @sir4ur0n and @matthew-healy since they have worked on the Nix flake not too long ago. |
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.
I haven't reviewed actual pyckel
part, only the Nix files
Thanks for tagging me, but I'm gonna remove myself from this PR since my experience editing the flake was pretty limited. I think Julien has a lot more context than I do on how it actually works. |
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.
Mostly LGTM. The CI running time is suspiciously high, but you've changed the nickel-lang-deps
derivation, which is the cornerstone of the build, so it might just be that this PR invalidated all previous cached artifacts. I took another look at the crane
doc, and the current PR, and I don't see why the artifacts wouldn't be cached again in the future.
Let's see in subsequent PRs if something looks wrong with respect to CI time.
Bringing python in is surprising for people who don't care about python bindings, suggesting that said bindings could also be in their own repo. But I guess Python is a well-cached, not-too-big derivation, and it's fine as it is for now.
Co-authored-by: Yann Hamdaoui <yann.hamdaoui@gmail.com>
Co-authored-by: Julien Debon <julien.debon@protonmail.com> Co-authored-by: Yann Hamdaoui <yann.hamdaoui@gmail.com>
2ce98fc
to
76782d6
Compare
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.
Approving as in "Nothing looks off in the Nix code". I haven't tried it, nor looked at the Python/Rust part
Ok, let's keep an eye on CI times, but otherwise LGTM. |
This PR adds very simple Python bindings. Fixes #820.
It builds a package
nickel-lang
with a modulenickel_lang
containing a single functionrun
which takes in astr
of a Nickel expression and returns the result asstr
.The Python module is built using maturin.
Note that building the Python modules part is Rust is optional, the binary shouldn't be bigger.
To test this PR:
pyckel
folderpython -m venv .venv source .venv/bin/activate
pip install "maturin>=0.14,<0.15"
nickel_lang
Python module to the local venvThis PR does not
Todo:
run
should return JSONrun
should evaluate fully