From 65477dcd341dcdcdc58b01e362e18a903bf94874 Mon Sep 17 00:00:00 2001 From: Masayuki Takeda Date: Wed, 24 May 2017 22:12:24 +0900 Subject: [PATCH] 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. --- pkgs/top-level/python-packages.nix | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index eccf1047cc4..a896e7a4e9e 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -53,15 +53,11 @@ let let 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;}; - - fetchSource = {pname, version, sha256}: + fetchSource = {pname, version, sha256, extension ? "tar.gz"}: # Fetch a source tarball. let - urls = [ - "mirror://pypi/${builtins.substring 0 1 pname}/${pname}/${pname}-${version}.tar.gz" - "mirror://pypi/${builtins.substring 0 1 pname}/${pname}/${pname}-${version}.zip" - ]; - in pkgs.fetchurl {inherit urls sha256;}; + url = "mirror://pypi/${builtins.substring 0 1 pname}/${pname}/${pname}-${version}.${extension}"; + in pkgs.fetchurl {inherit url sha256;}; fetcher = (if format == "wheel" then fetchWheel else if format == "setuptools" then fetchSource else throw "Unsupported kind ${kind}");