summary refs log tree commit diff
path: root/pkgs/development/python-modules/poetry/default.nix
blob: f007ff3df1d8ec8d17e38f7621387b81166038a9 (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
{ lib, buildPythonPackage, fetchPypi, callPackage
, isPy27, isPy34, pythonOlder
, cleo
, requests
, cachy
, requests-toolbelt
, pyrsistent
, pyparsing
, cachecontrol
, pkginfo
, html5lib
, shellingham
, subprocess32
, tomlkit
, typing
, pathlib2
, virtualenv
, functools32
, clikit
, keyring
, pexpect
, importlib-metadata
, pytest
, jsonschema
, intreehooks
, lockfile
}:

let
  glob2 = callPackage ./glob2.nix { };

in buildPythonPackage rec {
  pname = "poetry";
  version = "1.0.5";
  format = "pyproject";

  src = fetchPypi {
    inherit pname version;
    sha256 = "0y528095njf28isbcp5iwbf12j67xhxnrkac93pws0zy133v7kc1";
  };

  postPatch = ''
    substituteInPlace pyproject.toml \
     --replace "pyrsistent = \"^0.14.2\"" "pyrsistent = \"^0.15.0\"" \
     --replace "requests-toolbelt = \"^0.8.0\"" "requests-toolbelt = \"^0.9.0\"" \
     --replace 'importlib-metadata = {version = "~1.1.3", python = "<3.8"}' \
       'importlib-metadata = {version = ">=1.3,<2", python = "<3.8"}'
  '';

  nativeBuildInputs = [ intreehooks ];

  propagatedBuildInputs = [
    cleo
    clikit
    requests
    cachy
    requests-toolbelt
    jsonschema
    pyrsistent
    pyparsing
    cachecontrol
    pkginfo
    html5lib
    shellingham
    tomlkit
    pexpect
    keyring
    lockfile
  ] ++ lib.optionals (isPy27 || isPy34) [ typing pathlib2 glob2 ]
    ++ lib.optionals isPy27 [ virtualenv functools32 subprocess32 ]
    ++ 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"
  '';

  # No tests in Pypi tarball
  doCheck = false;
  checkInputs = [ pytest ];
  checkPhase = ''
    pytest tests
  '';

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