Skip to content

init fetchPipMetadata / pip #504

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

Merged
merged 68 commits into from
Apr 20, 2023
Merged

Conversation

phaer
Copy link
Member

@phaer phaer commented Apr 4, 2023

This PR forks fetchPip and mach-nix-xs into new fetchPipMetadata and pip modules. This happens in order to allow us to experiment with two quite different approaches on howto handle python packaging.

In short: fetchPipMetadata is now a normal, non-sandboxed script which uses pips install report only to acquire dependency metadata to write into a lock file. This lock file is then used by pip to build a granular tree of python package derivations with normal nixpkgs fetchers and without a FOD or IFD, which positively affects performance.

Writing all package metadata, including urls and hashes of packages, directly into the lock file also allows easier inspection of changes using diffs of said lock file.

Drv substitutions are out of scope for this PR, and nixpkgs-overrides can be enabled on a per-package basis. There's also preliminary support for pythons environment markers and editable installs (for the toplevel package).

phaer added 28 commits March 31, 2023 14:05
...and report.json for now
...to simplify for now, we'll re-introduce it later
...remove the venv and wait for the proxy via http, because the
cert is only generated a bit after mitmproxy is started
...and the venv. Also make hash gathering more solid
buildInputs. There's probably a cleaner way
for proper support of platform-specific and optional features.
Turns out it, it isn't that hard after all with a bit of recursion.
...to prevent inifite recursion in nix later on
...but don't activate it by default
};
mkDerivation = {
src = l.mkDefault (l.fetchurl {inherit (metadata.${config.name}) url sha256;});
doCheck = l.mkDefault false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe default to true

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried to do so, but that causes lots of failures because most packages don't include their requirements to run the tests in the default set.

I'd like to leave it like that for now as I am going to add an interface to request "extras" soon. Together with a method to set default for all .drvs in a package, this would allow us to add {"test", "tests"} to extras by default if doCheckis true, which should solve that problem for most packages in a cleaner way.

phaer added 4 commits April 6, 2023 12:55
...using a map() instead of list-comprehension resulted in an
iterator which was consumed in the first branch of our dependency
tree where it was encountered, resulting in an empty set of
requirements in other branches.
@phaer phaer force-pushed the fetch-pip-metadata branch from c067046 to 7416e44 Compare April 7, 2023 10:03
@phaer phaer marked this pull request as ready for review April 7, 2023 15:22
@phaer phaer force-pushed the fetch-pip-metadata branch 3 times, most recently from ae4d21f to 3472d8b Compare April 19, 2023 08:45
@phaer phaer force-pushed the fetch-pip-metadata branch from 3472d8b to 2a27fce Compare April 19, 2023 17:02
@phaer phaer merged commit 51797eb into nix-community:main Apr 20, 2023
@phaer phaer mentioned this pull request Apr 20, 2023
13 tasks
@phaer phaer deleted the fetch-pip-metadata branch April 20, 2023 09:06
@raj-magesh
Copy link

Exciting work! Would this enable editable installs for multiple packages (as described here: NixOS/nixpkgs#11957 (comment))?

@phaer
Copy link
Member Author

phaer commented May 11, 2023

@raj-magesh Thanks! While this can buiild many python packages, we haven't added devShells yet. There's a prototype which iiuc should be able to support editable installs for multiple packages, but we still need to finish a few things - such as switching dev dependencies on and off from the same lock file, you'd currently need to re-lock. I'd expect a pull request in the next month or so :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants