2019-07-11 14:06:32 +00:00
|
|
|
# `fetchPypi` function for fetching artifacts from PyPI.
|
|
|
|
{ fetchurl
|
|
|
|
, makeOverridable
|
|
|
|
}:
|
|
|
|
|
2019-07-11 14:17:31 +00:00
|
|
|
let
|
|
|
|
computeUrl = {format ? "setuptools", ... } @attrs: let
|
2021-06-19 00:09:03 +00:00
|
|
|
computeWheelUrl = {pname, version, dist ? "py2.py3", python ? "py2.py3", abi ? "none", platform ? "any"}:
|
2019-07-11 14:06:32 +00:00
|
|
|
# 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.
|
2021-06-19 00:09:03 +00:00
|
|
|
"https://files.pythonhosted.org/packages/${dist}/${builtins.substring 0 1 pname}/${pname}/${pname}-${version}-${python}-${abi}-${platform}.whl";
|
2019-07-11 14:17:31 +00:00
|
|
|
|
|
|
|
computeSourceUrl = {pname, version, extension ? "tar.gz"}:
|
2019-07-11 14:06:32 +00:00
|
|
|
# Fetch a source tarball.
|
2019-07-11 14:17:31 +00:00
|
|
|
"mirror://pypi/${builtins.substring 0 1 pname}/${pname}/${pname}-${version}.${extension}";
|
|
|
|
|
|
|
|
compute = (if format == "wheel" then computeWheelUrl
|
|
|
|
else if format == "setuptools" then computeSourceUrl
|
2019-07-11 14:06:32 +00:00
|
|
|
else throw "Unsupported format ${format}");
|
2019-07-11 14:17:31 +00:00
|
|
|
|
|
|
|
in compute (builtins.removeAttrs attrs ["format"]);
|
|
|
|
|
2019-07-11 14:28:46 +00:00
|
|
|
in makeOverridable( {format ? "setuptools", sha256 ? "", hash ? "", ... } @attrs:
|
2019-07-11 14:17:31 +00:00
|
|
|
let
|
2019-07-11 14:28:46 +00:00
|
|
|
url = computeUrl (builtins.removeAttrs attrs ["sha256" "hash"]) ;
|
2019-07-11 14:17:31 +00:00
|
|
|
in fetchurl {
|
2019-07-11 14:28:46 +00:00
|
|
|
inherit url sha256 hash;
|
2019-07-11 14:17:31 +00:00
|
|
|
})
|