nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ lib
2, buildPythonPackage
3, cachecontrol
4, cachy
5, cleo
6, clikit
7, crashtest
8, dataclasses
9, entrypoints
10, fetchFromGitHub
11, fetchpatch
12, html5lib
13, httpretty
14, importlib-metadata
15, intreehooks
16, keyring
17, lockfile
18, packaging
19, pexpect
20, pkginfo
21, poetry-core
22, pytest-mock
23, pytestCheckHook
24, pythonAtLeast
25, pythonOlder
26, requests
27, requests-toolbelt
28, shellingham
29, tomlkit
30, virtualenv
31}:
32
33buildPythonPackage rec {
34 pname = "poetry";
35 version = "1.1.12";
36 format = "pyproject";
37
38 disabled = pythonOlder "3.6";
39
40 src = fetchFromGitHub {
41 owner = "python-poetry";
42 repo = pname;
43 rev = version;
44 sha256 = "1fm4yj6wxr24v7b77gmf63j7xsgszhbhzw2i9fvlfi0p9l0q34pm";
45 };
46
47 postPatch = ''
48 substituteInPlace pyproject.toml \
49 --replace 'importlib-metadata = {version = "^1.6.0", python = "<3.8"}' \
50 'importlib-metadata = {version = ">=1.6", python = "<3.8"}' \
51 --replace 'version = "^21.2.0"' 'version = ">=21.2"' \
52 --replace 'packaging = "^20.4"' 'packaging = "*"'
53 '';
54
55 nativeBuildInputs = [
56 intreehooks
57 ];
58
59 propagatedBuildInputs = [
60 cachecontrol
61 cachy
62 cleo
63 clikit
64 crashtest
65 entrypoints
66 html5lib
67 keyring
68 lockfile
69 packaging
70 pexpect
71 pkginfo
72 poetry-core
73 requests
74 requests-toolbelt
75 shellingham
76 tomlkit
77 virtualenv
78 ] ++ lib.optionals (pythonOlder "3.7") [
79 dataclasses
80 ] ++ lib.optionals (pythonOlder "3.8") [
81 importlib-metadata
82 ];
83
84 postInstall = ''
85 mkdir -p "$out/share/bash-completion/completions"
86 "$out/bin/poetry" completions bash > "$out/share/bash-completion/completions/poetry"
87 mkdir -p "$out/share/zsh/vendor-completions"
88 "$out/bin/poetry" completions zsh > "$out/share/zsh/vendor-completions/_poetry"
89 mkdir -p "$out/share/fish/vendor_completions.d"
90 "$out/bin/poetry" completions fish > "$out/share/fish/vendor_completions.d/poetry.fish"
91 '';
92
93 checkInputs = [
94 pytestCheckHook
95 httpretty
96 pytest-mock
97 ];
98
99 preCheck = ''
100 export HOME=$TMPDIR
101 '';
102
103 disabledTests = [
104 # touches network
105 "git"
106 "solver"
107 "load"
108 "vcs"
109 "prereleases_if_they_are_compatible"
110 "test_executor"
111 # requires git history to work correctly
112 "default_with_excluded_data"
113 # toml ordering has changed
114 "lock"
115 # fs permission errors
116 "test_builder_should_execute_build_scripts"
117 ] ++ lib.optionals (pythonAtLeast "3.10") [
118 # RuntimeError: 'auto_spec' might be a typo; use unsafe=True if this is intended
119 "test_info_setup_complex_pep517_error"
120 ];
121
122 patches = [
123 # The following patch addresses a minor incompatibility with
124 # pytest-mock. This is addressed upstream in
125 # https://github.com/python-poetry/poetry/pull/3457
126 (fetchpatch {
127 url = "https://github.com/python-poetry/poetry/commit/8ddceb7c52b3b1f35412479707fa790e5d60e691.diff";
128 sha256 = "yHjFb9xJBLFOqkOZaJolKviTdtST9PMFwH9n8ud2Y+U=";
129 })
130 ];
131
132 # Allow for package to use pep420's native namespaces
133 pythonNamespaces = [
134 "poetry"
135 ];
136
137 meta = with lib; {
138 homepage = "https://python-poetry.org/";
139 description = "Python dependency management and packaging made easy";
140 license = licenses.mit;
141 maintainers = with maintainers; [ jakewaksbaum ];
142 };
143}