audiobookshelf: 2.18.1 -> 2.19.0 (#378967)
[NixPkgs.git] / pkgs / by-name / po / poetry / package.nix
blob730fdbbc714055a8c26079384c5a4a013b13bcba
2   lib,
3   python3,
4   fetchFromGitHub,
5 }:
7 let
8   newPackageOverrides =
9     self: super:
10     {
11       poetry = self.callPackage ./unwrapped.nix { };
13       # The versions of Poetry and poetry-core need to match exactly,
14       # and poetry-core in nixpkgs requires a staging cycle to be updated,
15       # so apply an override here.
16       #
17       # We keep the override around even when the versions match, as
18       # it's likely to become relevant again after the next Poetry update.
19       poetry-core = super.poetry-core.overridePythonAttrs (old: rec {
20         version = "2.0.0";
21         src = fetchFromGitHub {
22           owner = "python-poetry";
23           repo = "poetry-core";
24           tag = version;
25           hash = "sha256-3dmvFn2rxtR0SK8oiEHIVJhpJpX4Mm/6kZnIYNSDv90=";
26         };
27         patches = [ ];
28         nativeCheckInputs =
29           old.nativeCheckInputs
30           ++ (with self; [
31             trove-classifiers
32           ]);
33         disabledTests = old.disabledTests ++ [
34           # relies on git
35           "test_package_with_include"
36           # Nix changes timestamp
37           "test_dist_info_date_time_default_value"
38           "test_sdist_members_mtime_default"
39           "test_sdist_mtime_zero"
40         ];
41       });
42     }
43     // (plugins self);
44   python = python3.override (old: {
45     self = python;
46     packageOverrides = lib.composeManyExtensions (
47       (if old ? packageOverrides then [ old.packageOverrides ] else [ ]) ++ [ newPackageOverrides ]
48     );
49   });
51   plugins =
52     ps: with ps; {
53       poetry-audit-plugin = callPackage ./plugins/poetry-audit-plugin.nix { };
54       poetry-plugin-export = callPackage ./plugins/poetry-plugin-export.nix { };
55       poetry-plugin-up = callPackage ./plugins/poetry-plugin-up.nix { };
56       poetry-plugin-poeblix = callPackage ./plugins/poetry-plugin-poeblix.nix { };
57       poetry-plugin-shell = callPackage ./plugins/poetry-plugin-shell.nix { };
58     };
60   # selector is a function mapping pythonPackages to a list of plugins
61   # e.g. poetry.withPlugins (ps: with ps; [ poetry-plugin-up ])
62   withPlugins =
63     selector:
64     let
65       selected = selector (plugins python.pkgs);
66     in
67     python.pkgs.toPythonApplication (
68       python.pkgs.poetry.overridePythonAttrs (old: {
69         dependencies = old.dependencies ++ selected;
71         # save some build time when adding plugins by disabling tests
72         doCheck = selected == [ ];
74         # Propagating dependencies leaks them through $PYTHONPATH which causes issues
75         # when used in nix-shell.
76         postFixup = ''
77           rm $out/nix-support/propagated-build-inputs
78         '';
80         passthru = {
81           plugins = plugins python.pkgs;
82           inherit withPlugins python;
83         };
84       })
85     );
87 withPlugins (ps: [ ])