mirror of
https://github.com/vale981/poetry2nix
synced 2025-03-06 17:51:40 -05:00
Merge pull request #1110 from charmoniumQ/patch-1
This commit is contained in:
commit
4b55ce49b7
1 changed files with 48 additions and 0 deletions
|
@ -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.
|
Loading…
Add table
Reference in a new issue