diff options
author | Frederik Rietdijk <fridh@fridh.nl> | 2019-07-11 16:17:31 +0200 |
---|---|---|
committer | Frederik Rietdijk <freddyrietdijk@fridh.nl> | 2019-07-11 18:01:04 +0200 |
commit | 30f299027a5d24b51fd7e0f6cf8c8a74495e8ea8 (patch) | |
tree | 46fd8f2701b08727aa153d224ea7382f4fdbe719 /pkgs/development/interpreters | |
parent | f2a81174922c1bd1875e2b1b09c29565226c30db (diff) | |
download | nixlib-30f299027a5d24b51fd7e0f6cf8c8a74495e8ea8.tar nixlib-30f299027a5d24b51fd7e0f6cf8c8a74495e8ea8.tar.gz nixlib-30f299027a5d24b51fd7e0f6cf8c8a74495e8ea8.tar.bz2 nixlib-30f299027a5d24b51fd7e0f6cf8c8a74495e8ea8.tar.lz nixlib-30f299027a5d24b51fd7e0f6cf8c8a74495e8ea8.tar.xz nixlib-30f299027a5d24b51fd7e0f6cf8c8a74495e8ea8.tar.zst nixlib-30f299027a5d24b51fd7e0f6cf8c8a74495e8ea8.zip |
pythonPackages.fetchPypi: separate url computation from fetchurl
Diffstat (limited to 'pkgs/development/interpreters')
-rw-r--r-- | pkgs/development/interpreters/python/fetchpypi.nix | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/pkgs/development/interpreters/python/fetchpypi.nix b/pkgs/development/interpreters/python/fetchpypi.nix index ece4e136d3f8..91dd331e6f3e 100644 --- a/pkgs/development/interpreters/python/fetchpypi.nix +++ b/pkgs/development/interpreters/python/fetchpypi.nix @@ -3,20 +3,26 @@ , makeOverridable }: -makeOverridable( {format ? "setuptools", ... } @attrs: - let - fetchWheel = {pname, version, sha256, python ? "py2.py3", abi ? "none", platform ? "any"}: +let + computeUrl = {format ? "setuptools", ... } @attrs: let + computeWheelUrl = {pname, version, 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. - let - url = "https://files.pythonhosted.org/packages/${python}/${builtins.substring 0 1 pname}/${pname}/${pname}-${version}-${python}-${abi}-${platform}.whl"; - in fetchurl {inherit url sha256;}; - fetchSource = {pname, version, sha256, extension ? "tar.gz"}: + "https://files.pythonhosted.org/packages/${python}/${builtins.substring 0 1 pname}/${pname}/${pname}-${version}-${python}-${abi}-${platform}.whl"; + + computeSourceUrl = {pname, version, extension ? "tar.gz"}: # Fetch a source tarball. - let - url = "mirror://pypi/${builtins.substring 0 1 pname}/${pname}/${pname}-${version}.${extension}"; - in fetchurl {inherit url sha256;}; - fetcher = (if format == "wheel" then fetchWheel - else if format == "setuptools" then fetchSource + "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 fetcher (builtins.removeAttrs attrs ["format"]) ) \ No newline at end of file + + in compute (builtins.removeAttrs attrs ["format"]); + +in makeOverridable( {format ? "setuptools", sha256, ... } @attrs: + let + url = computeUrl (builtins.removeAttrs attrs ["sha256"]) ; + in fetchurl { + inherit url sha256; + }) |