-
-
Notifications
You must be signed in to change notification settings - Fork 13.7k
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
python3Packages.mkPythonEditablePackage: init #339228
Conversation
ae38f41
to
9c3c75a
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.
Thank you for this!
Think i found a typo, commented a bit on docs and found a single semantic change I'd like to see: prepending, not appending to sys.path
.
e37568f
to
41611f8
Compare
Unless someone gives me a good reason not to I intend to self-merge this sooner rather than later. |
dcc7cf2
to
85465d3
Compare
I'm not sure if adding more |
85465d3
to
567695e
Compare
No. We need to create package metadata and pointer files in the store as regular Python packages, and these should be built without sources. There is no place to set up a hook to get editable behaviour for development shells. |
567695e
to
de1fdc9
Compare
I could conjure up an implementation of a hook-based editable builder, but it's usage would have to look like: buildPythonPackage {
pname = "my-editable";
version = "0.1.0";
# Assuming that you'd want to use pyproject.toml from current directory, don't know if there is a more elegant way to express this
# If you'd forget to filter your sources the point of the editable is kinda moot since you'd rebuild all the time anyway.
src = lib.filesets.toSource {
root = ./.;
fileset = [ ./pyproject.toml ];
};
pyproject = true;
editableRoot = "$REPO_ROOT";
nativeBuildInputs = [
editablePatchHook # Patches pyproject.toml with the editable root build and forces hatchling to be the build-system
];
} That's a lot of stuff to get right every time for every user. I prefer a function abstraction based approach in this instance, even though I generally agree that we should move towards hooks. |
Giving a 24 hour notice to merge. |
Is the primary concern the handling of |
That's one of the main two concerns, but also handling of By making it a hook it's not possible to enforce the type of
I think this is really the core of it. This is a development helper, not a composable builder. |
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.
Thanks for your explanation. I support this implementation.
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 think this a good step forward, thank you!
Description of changes
When developing Python packages it's common to install packages in editable mode.
Like
mkPythonMetaPackage
this function exists to create an otherwise empty package, but also containing a pointer to an impure location outside the Nix store that can be changed without rebuilding.The editable root is passed as a string. Normally
.pth
files contains absolute paths to the mutable location. This isn't always ergonomic with Nix, so I have decided to expand environment variables at runtime.This means that a shell hook setting up something like a
$REPO_ROOT
variable can be used as the relative package root.Note that overriding packages deeper in the dependency graph can work, but it's not the primary usecase and overriding existing packages can make others break in unexpected ways.
Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.