1 # `fetchPypi` function for fetching artifacts from PyPI.
7 computeUrl = {format ? "setuptools", ... } @attrs: let
8 computeWheelUrl = {pname, version, dist ? "py2.py3", python ? "py2.py3", abi ? "none", platform ? "any"}:
9 # Fetch a wheel. By default we fetch an universal wheel.
10 # See https://www.python.org/dev/peps/pep-0427/#file-name-convention for details regarding the optional arguments.
11 "https://files.pythonhosted.org/packages/${dist}/${builtins.substring 0 1 pname}/${pname}/${pname}-${version}-${python}-${abi}-${platform}.whl";
13 computeSourceUrl = {pname, version, extension ? "tar.gz"}:
14 # Fetch a source tarball.
15 "mirror://pypi/${builtins.substring 0 1 pname}/${pname}/${pname}-${version}.${extension}";
17 compute = (if format == "wheel" then computeWheelUrl
18 else if format == "setuptools" then computeSourceUrl
19 else throw "Unsupported format ${format}");
21 in compute (builtins.removeAttrs attrs ["format"]);
23 in makeOverridable( {format ? "setuptools", sha256 ? "", hash ? "", ... } @attrs:
25 url = computeUrl (builtins.removeAttrs attrs ["sha256" "hash"]) ;
27 inherit url sha256 hash;