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