aboutsummaryrefslogtreecommitdiff
path: root/infra/libkookie/nixpkgs/pkgs/development/interpreters/python/fetchpypi.nix
diff options
context:
space:
mode:
authorMx Kookie <kookie@spacekookie.de>2020-10-31 19:35:09 +0100
committerMx Kookie <kookie@spacekookie.de>2020-10-31 19:35:09 +0100
commitc4625b175f8200f643fd6e11010932ea44c78433 (patch)
treebce3f89888c8ac3991fa5569a878a9eab6801ccc /infra/libkookie/nixpkgs/pkgs/development/interpreters/python/fetchpypi.nix
parent49f735974dd103039ddc4cb576bb76555164a9e7 (diff)
parentd661aa56a8843e991261510c1bb28fdc2f6975ae (diff)
Add 'infra/libkookie/' from commit 'd661aa56a8843e991261510c1bb28fdc2f6975ae'
git-subtree-dir: infra/libkookie git-subtree-mainline: 49f735974dd103039ddc4cb576bb76555164a9e7 git-subtree-split: d661aa56a8843e991261510c1bb28fdc2f6975ae
Diffstat (limited to 'infra/libkookie/nixpkgs/pkgs/development/interpreters/python/fetchpypi.nix')
-rw-r--r--infra/libkookie/nixpkgs/pkgs/development/interpreters/python/fetchpypi.nix28
1 files changed, 28 insertions, 0 deletions
diff --git a/infra/libkookie/nixpkgs/pkgs/development/interpreters/python/fetchpypi.nix b/infra/libkookie/nixpkgs/pkgs/development/interpreters/python/fetchpypi.nix
new file mode 100644
index 000000000000..e60c9df1f8bb
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/development/interpreters/python/fetchpypi.nix
@@ -0,0 +1,28 @@
+# `fetchPypi` function for fetching artifacts from PyPI.
+{ fetchurl
+, makeOverridable
+}:
+
+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.
+ "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.
+ "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 compute (builtins.removeAttrs attrs ["format"]);
+
+in makeOverridable( {format ? "setuptools", sha256 ? "", hash ? "", ... } @attrs:
+ let
+ url = computeUrl (builtins.removeAttrs attrs ["sha256" "hash"]) ;
+ in fetchurl {
+ inherit url sha256 hash;
+ })