Merge pull request #1110 from charmoniumQ/patch-1

This commit is contained in:
Phillip Cloud 2023-05-01 04:51:00 -07:00 committed by GitHub
commit 4b55ce49b7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -167,6 +167,33 @@ poetry2nix.mkPoetryApplication {
}
```
If you need very many of these overrides or you need to use them twice, consider using something like this. It has less repetition:
```nix
let
pypkgs-build-requirements = {
tox = [ "hatchling" "hatch-vcs" ];
universal-pathlib = [ "flit-core" ];
pygithub = [ "setuptools-scm" ];
beautifulsoup4 = [ "hatchling" ];
xyzservices = [ "setuptools" ];
simpervisor = [ "setuptools" ];
pandas = [ "versioneer" ];
};
p2n-overrides = p2n.defaultPoetryOverrides.extend (self: super:
builtins.mapAttrs (package: build-requirements:
(builtins.getAttr package super).overridePythonAttrs (old: {
buildInputs = (old.buildInputs or [ ]) ++ (builtins.map (pkg: if builtins.isString pkg then builtins.getAttr pkg super else pkg) build-requirements);
})
) pypkgs-build-requirements
);
in
poetry2nix.mkPoetryApplication {
projectDir = ./.;
overrides = p2n-overrides;
}
```
We recommend that you contribute your changes to `poetry2nix` so that other users can profit from them as well.
The specific file with the upstream overrides is [build-systems.json](https://github.com/nix-community/poetry2nix/blob/master/overrides/build-systems.json). It is a simple JSON file which contains the overrides in an array and sorted in alphabetical order.
@ -192,3 +219,24 @@ Resulting override:
);
}
```
#### Nix evaluation errors
1. Enable `--show-trace`.
2. Remove packages from the `pyproject.toml`, `rm poetry.lock && nix shell nixpkgs#poetry --command poetry lock`.
3. Try running poetry2nix again.
By these means, one can bisect the package-set to find the problematic package.
One error you might run into is an "infinite recursion encountered." If this error indicates this happens happens `while evaluating the attribute 'propagatedBuildInputs' of the derivation 'python${version}-${pkg_name}'`, then it is possible `${pkg_name}` has a recursive dependency.
For example, this is the abbreviated error message if I try to install `dask[distributed]`:
```
error: infinite recursion encountered
… while evaluating the attribute 'propagatedBuildInputs' of the derivation 'python3.11-distributed-2023.3.2'
… while evaluating the attribute 'propagatedBuildInputs' of the derivation 'python3.11-dask-2023.3.2'
… while evaluating the attribute 'propagatedBuildInputs' of the derivation 'python3.11-main-0.1.0'
```
This is because `dask[distributed]` depends on `distributed` which depends on `dask`. The solution is to install `dask` (no extras) and `distributed` separately.