2024-05-02 00:46:19 +00:00
|
|
|
# `fetchPypi` function for fetching artifacts from PyPI.
|
2024-06-30 08:16:52 +00:00
|
|
|
{ fetchurl, makeOverridable }:
|
2024-05-02 00:46:19 +00:00
|
|
|
|
|
|
|
let
|
2024-06-30 08:16:52 +00:00
|
|
|
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";
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:16:52 +00:00
|
|
|
computeSourceUrl =
|
|
|
|
{
|
|
|
|
pname,
|
|
|
|
version,
|
|
|
|
extension ? "tar.gz",
|
|
|
|
}:
|
|
|
|
# Fetch a source tarball.
|
|
|
|
"mirror://pypi/${builtins.substring 0 1 pname}/${pname}/${pname}-${version}.${extension}";
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:16:52 +00:00
|
|
|
compute = (
|
|
|
|
if format == "wheel" then
|
|
|
|
computeWheelUrl
|
|
|
|
else if format == "setuptools" then
|
|
|
|
computeSourceUrl
|
|
|
|
else
|
|
|
|
throw "Unsupported format ${format}"
|
|
|
|
);
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:16:52 +00:00
|
|
|
in
|
|
|
|
compute (builtins.removeAttrs attrs [ "format" ]);
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:16:52 +00:00
|
|
|
in
|
|
|
|
makeOverridable (
|
|
|
|
{
|
|
|
|
format ? "setuptools",
|
|
|
|
sha256 ? "",
|
|
|
|
hash ? "",
|
|
|
|
...
|
|
|
|
}@attrs:
|
2024-05-02 00:46:19 +00:00
|
|
|
let
|
2024-06-30 08:16:52 +00:00
|
|
|
url = computeUrl (
|
|
|
|
builtins.removeAttrs attrs [
|
|
|
|
"sha256"
|
|
|
|
"hash"
|
|
|
|
]
|
|
|
|
);
|
|
|
|
in
|
|
|
|
fetchurl { inherit url sha256 hash; }
|
|
|
|
)
|