about summary refs log tree commit diff
path: root/pkgs/development/python-modules/poetry/default.nix
blob: 5efbe56ac5bddcea0c27e612c4f7af95f58e4a74 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
{ lib
, buildPythonPackage
, cachecontrol
, cachy
, cleo
, clikit
, crashtest
, dataclasses
, entrypoints
, fetchFromGitHub
, fetchpatch
, html5lib
, httpretty
, importlib-metadata
, intreehooks
, keyring
, lockfile
, packaging
, pexpect
, pkginfo
, poetry-core
, pytest-mock
, pytestCheckHook
, pythonAtLeast
, pythonOlder
, requests
, requests-toolbelt
, shellingham
, tomlkit
, virtualenv
}:

buildPythonPackage rec {
  pname = "poetry";
  version = "1.1.12";
  format = "pyproject";

  disabled = pythonOlder "3.6";

  src = fetchFromGitHub {
    owner = "python-poetry";
    repo = pname;
    rev = version;
    sha256 = "1fm4yj6wxr24v7b77gmf63j7xsgszhbhzw2i9fvlfi0p9l0q34pm";
  };

  postPatch = ''
    substituteInPlace pyproject.toml \
      --replace 'importlib-metadata = {version = "^1.6.0", python = "<3.8"}' \
       'importlib-metadata = {version = ">=1.6", python = "<3.8"}' \
      --replace 'version = "^21.2.0"' 'version = ">=21.2"' \
      --replace 'packaging = "^20.4"' 'packaging = "*"'
  '';

  nativeBuildInputs = [
    intreehooks
  ];

  propagatedBuildInputs = [
    cachecontrol
    cachy
    cleo
    clikit
    crashtest
    entrypoints
    html5lib
    keyring
    lockfile
    packaging
    pexpect
    pkginfo
    poetry-core
    requests
    requests-toolbelt
    shellingham
    tomlkit
    virtualenv
  ] ++ lib.optionals (pythonOlder "3.7") [
    dataclasses
  ] ++ lib.optionals (pythonOlder "3.8") [
    importlib-metadata
  ];

  postInstall = ''
    mkdir -p "$out/share/bash-completion/completions"
    "$out/bin/poetry" completions bash > "$out/share/bash-completion/completions/poetry"
    mkdir -p "$out/share/zsh/vendor-completions"
    "$out/bin/poetry" completions zsh > "$out/share/zsh/vendor-completions/_poetry"
    mkdir -p "$out/share/fish/vendor_completions.d"
    "$out/bin/poetry" completions fish > "$out/share/fish/vendor_completions.d/poetry.fish"
  '';

  checkInputs = [
    pytestCheckHook
    httpretty
    pytest-mock
  ];

  preCheck = ''
    export HOME=$TMPDIR
  '';

  disabledTests = [
    # touches network
    "git"
    "solver"
    "load"
    "vcs"
    "prereleases_if_they_are_compatible"
    "test_executor"
    # requires git history to work correctly
    "default_with_excluded_data"
    # toml ordering has changed
    "lock"
    # fs permission errors
    "test_builder_should_execute_build_scripts"
  ] ++ lib.optionals (pythonAtLeast "3.10") [
    # RuntimeError: 'auto_spec' might be a typo; use unsafe=True if this is intended
    "test_info_setup_complex_pep517_error"
  ];

  patches = [
    # The following patch addresses a minor incompatibility with
    # pytest-mock. This is addressed upstream in
    # https://github.com/python-poetry/poetry/pull/3457
    (fetchpatch {
      url = "https://github.com/python-poetry/poetry/commit/8ddceb7c52b3b1f35412479707fa790e5d60e691.diff";
      sha256 = "yHjFb9xJBLFOqkOZaJolKviTdtST9PMFwH9n8ud2Y+U=";
    })
  ];

  # Allow for package to use pep420's native namespaces
  pythonNamespaces = [
    "poetry"
  ];

  meta = with lib; {
    homepage = "https://python-poetry.org/";
    description = "Python dependency management and packaging made easy";
    license = licenses.mit;
    maintainers = with maintainers; [ jakewaksbaum ];
  };
}