-
Notifications
You must be signed in to change notification settings - Fork 0
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: add Value
type
#17
base: python-bindings
Are you sure you want to change the base?
Conversation
And fix a test failure in the sandbox due to /home existing on Darwin but not being accessible in the sandbox since it's a symlink to /System/Volumes/Data/home, see https://github.com/NixOS/nix/actions/runs/4205378453/jobs/7297384658#step:6:2127: C++ exception with description "error: getting status of /home/schnitzel/darmstadt/pommes: Operation not permitted" thrown in the test body. On Linux this wasn't a problem because there /home doesn't exist in the sandbox
Copies part of the tree from Pythonix at Mic92/pythonix@fbc8490 into the ./python subdirectory. These Python bindings don't build yet with the current Nix version, which is why they're not built yet in this commit. Mic92 confirmed that he's okay with the license being changed to the Nix one: NixOS#7735 (comment) Co-Authored-By: Jörg Thalheim <[email protected]>
The python bindings initialised from Pythonix haven't been updated in some Nix versions and would not compile anymore. This commit still doesn't include a working python bindings build, but these are the Nix-update-caused changes that will be necessary for that
Makes the python bindings build, both incrementally and for CI. Documentation is not yet included
Using the configuration file from NixOS#6721 for less conflicts
Will be useful for documentation
And don't use the deprecated python3 meson module
Not sure why I added it originally
Mirroring what the main Nix build does
And test that null bytes currently end strings
It didn't cause a problem because it converted True to 1, which still allowed 1 == True to succeed in Python (using assertEqual)
That in fact doesn't work for importing
Using a symlink hacky and breaks in some ways
So that we don't have to rebuild Nix every time the python bindings change
- BASH_SOURCE[0] doesn't exist for evaluations under `eval` - NIX_STORE may not be set
The former is deprecated
Previously the python bindings derivation would use Nix as its source, call configure on that, just to extract the two files tests/init.sh and (the generated one) tests/common/vars-and-functions.sh The new approach is to instead have a separate derivation extracting these two files and having a small wrapper around them
Tests that the Nix bindings can be used as a Python dependency in Nix builds
Docs still needed
Creating a new one for each call is wasteful and doesn't scale to a composable interface, as the same EvalState must be used for operations on the same Values. Ideally we'd store EvalState in the python module, or make it a first class object.
Did you see https://gist.github.com/yorickvP/08afdaae98cad3516a9629e7e8df343d ? I think we can almost implement it with this and a python wrapper. Just need a way to
|
I did and I was inspired by it! Would you like to resume this?
Would be nice but not essential.
We need to perform an undecidable amount of evaluation to return that information, and that'd be a feature to implement in the evaluator itself. I don't think it's worth the effort. Instead, you could formalize the interface of the expression with a schema expressed in python. It makes the runtime type checking at the boundary easy and consistent. Haskell
Also nice to have. A combination of
Can be achieved by wrapping I think this PR is already a valid MVP. |
c87a1b4
to
51a003b
Compare
a5b7b85
to
0ca1c82
Compare
|
||
## Build integration | ||
|
||
In the future these Python bindings will be available from Nixpkgs as `python3Packages.nix`. |
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 the future these Python bindings will be available from Nixpkgs as `python3Packages.nix`. |
Let's not talk about the future here.
|
||
See [index.md](./doc/index.md), which is also rendered in the HTML manual. | ||
|
||
To hack on these bindings, see [hacking.md](./doc/hacking.md), also rendered in the HTML manual. |
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 seems empty though. Let's not reference things that don't exist, or create those things first.
|
||
## Documentation | ||
|
||
See [index.md](./doc/index.md), which is also rendered in the HTML manual. |
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 may be missing something but I don't see where it's rendered in the manual.
879901f
to
57e71a3
Compare
@infinisil I hope this helps. A custom type doesn't seem so bad!