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
|
# `fetchPypi` function for fetching artifacts from PyPI.
{
lib,
fetchurl,
}:
let
computeUrl =
{
format ? "setuptools",
...
}@attrs:
let
computeWheelUrl =
{
pname,
version,
dist ? "py2.py3",
python ? "py2.py3",
abi ? "none",
platform ? "any",
}:
# Fetch a wheel. By default we fetch an universal wheel.
# See https://www.python.org/dev/peps/pep-0427/#file-name-convention for details regarding the optional arguments.
"https://files.pythonhosted.org/packages/${dist}/${builtins.substring 0 1 pname}/${pname}/${pname}-${version}-${python}-${abi}-${platform}.whl";
computeSourceUrl =
{
pname,
version,
extension ? "tar.gz",
}:
# Fetch a source tarball.
"mirror://pypi/${builtins.substring 0 1 pname}/${pname}/${pname}-${version}.${extension}";
compute = (
if format == "wheel" then
computeWheelUrl
else if format == "setuptools" then
computeSourceUrl
else
throw "Unsupported format ${format}"
);
in
compute (removeAttrs attrs [ "format" ]);
in
lib.makeOverridable (
{
format ? "setuptools",
sha256 ? "",
hash ? "",
pname,
version,
...
}@attrs:
let
url = computeUrl (
removeAttrs attrs [
"sha256"
"hash"
]
);
meta = {
identifiers.purlParts = {
type = "pypi";
# https://github.com/package-url/purl-spec/blob/18fd3e395dda53c00bc8b11fe481666dc7b3807a/types-doc/pypi-definition.md
spec = "${pname}@${version}";
};
};
in
fetchurl {
inherit
url
sha256
hash
meta
;
}
)
|