Python fetchPypi: support an extension

Many source archives on PyPI are tar.gz archives.
Not all are, and therefore this commit adds the possibility
to set the extension of the archive.
This commit is contained in:
Masayuki Takeda 2017-05-24 22:12:24 +09:00 committed by Frederik Rietdijk
parent 812e8ed1b5
commit 65477dcd34

View File

@ -53,15 +53,11 @@ let
let let
url = "https://files.pythonhosted.org/packages/${python}/${builtins.substring 0 1 pname}/${pname}/${pname}-${version}-${python}-${abi}-${platform}.whl"; url = "https://files.pythonhosted.org/packages/${python}/${builtins.substring 0 1 pname}/${pname}/${pname}-${version}-${python}-${abi}-${platform}.whl";
in pkgs.fetchurl {inherit url sha256;}; in pkgs.fetchurl {inherit url sha256;};
fetchSource = {pname, version, sha256, extension ? "tar.gz"}:
fetchSource = {pname, version, sha256}:
# Fetch a source tarball. # Fetch a source tarball.
let let
urls = [ url = "mirror://pypi/${builtins.substring 0 1 pname}/${pname}/${pname}-${version}.${extension}";
"mirror://pypi/${builtins.substring 0 1 pname}/${pname}/${pname}-${version}.tar.gz" in pkgs.fetchurl {inherit url sha256;};
"mirror://pypi/${builtins.substring 0 1 pname}/${pname}/${pname}-${version}.zip"
];
in pkgs.fetchurl {inherit urls sha256;};
fetcher = (if format == "wheel" then fetchWheel fetcher = (if format == "wheel" then fetchWheel
else if format == "setuptools" then fetchSource else if format == "setuptools" then fetchSource
else throw "Unsupported kind ${kind}"); else throw "Unsupported kind ${kind}");