python packages: port away from buildPythonPackage -> stdenv.mkDerivation

in a future refactoring, maybe i can remove them from the special 'pkgs/python-packages' directory altogether
This commit is contained in:
Colin 2024-06-26 23:37:27 +00:00
parent fb7701027e
commit fbcf2aed41
12 changed files with 224 additions and 152 deletions

View File

@ -10,8 +10,8 @@ let
lib = pkgs.lib; lib = pkgs.lib;
unpatched = pkgs; unpatched = pkgs;
pythonPackagesOverlayFor = pkgs: py-final: py-prev: import ./python-packages { pythonPackagesOverlayFor = pkgs: pyFinal: _pyPrev: import ./python-packages {
inherit (py-final) callPackage; inherit (pyFinal) callPackage toPythonModule;
inherit pkgs; inherit pkgs;
}; };
final' = if final != null then final else pkgs.extend (_: _: sane-overlay); final' = if final != null then final else pkgs.extend (_: _: sane-overlay);

View File

@ -1,13 +1,13 @@
{ callPackage, pkgs }: { callPackage, pkgs, toPythonModule }:
{ {
depthcharge-tools = callPackage ./depthcharge-tools { }; depthcharge-tools = toPythonModule (callPackage ./depthcharge-tools { });
feedsearch-crawler = callPackage ./feedsearch-crawler { }; feedsearch-crawler = toPythonModule (callPackage ./feedsearch-crawler { });
fastcluster = callPackage ./fastcluster { }; fastcluster = toPythonModule (callPackage ./fastcluster { });
listparser = callPackage ./listparser { }; listparser = toPythonModule (callPackage ./listparser { });
ols = callPackage ./ols { }; ols = toPythonModule (callPackage ./ols { });
pa-dlna = callPackage ./pa-dlna { }; pa-dlna = toPythonModule (callPackage ./pa-dlna { });
pyln-bolt7 = callPackage ./pyln-bolt7 { }; pyln-bolt7 = toPythonModule (callPackage ./pyln-bolt7 { });
pyln-client = callPackage ./pyln-client { }; pyln-client = toPythonModule (callPackage ./pyln-client { });
pyln-proto = callPackage ./pyln-proto { }; pyln-proto = toPythonModule (callPackage ./pyln-proto { });
sane-lib = pkgs.sane-scripts.lib; sane-lib = pkgs.sane-scripts.lib;
} }

View File

@ -1,8 +1,11 @@
{ lib {
, buildPythonPackage lib,
, fetchFromGitHub fetchFromGitHub,
, setuptools pypaBuildHook,
}: buildPythonPackage rec { pypaInstallHook,
setuptools,
stdenv
}: stdenv.mkDerivation (finalAttrs: {
pname = "depthcharge-tools"; pname = "depthcharge-tools";
version = "0.6.2"; version = "0.6.2";
format = "setuptools"; format = "setuptools";
@ -10,10 +13,15 @@
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "alpernebbi"; owner = "alpernebbi";
repo = "depthcharge-tools"; repo = "depthcharge-tools";
rev = "v${version}"; rev = "v${finalAttrs.version}";
hash = "sha256-3xPRNDUXLOwYy8quMfYSiBfzQl4peauTloqtZBGbvlw="; hash = "sha256-3xPRNDUXLOwYy8quMfYSiBfzQl4peauTloqtZBGbvlw=";
}; };
nativeBuildInputs = [
pypaBuildHook
pypaInstallHook
];
propagatedBuildInputs = [ propagatedBuildInputs = [
setuptools #< needs `pkg_resources` at runtime setuptools #< needs `pkg_resources` at runtime
]; ];
@ -27,4 +35,4 @@
description = "Tools to manage the Chrome OS bootloader"; description = "Tools to manage the Chrome OS bootloader";
maintainers = with maintainers; [ colinsane ]; maintainers = with maintainers; [ colinsane ];
}; };
} })

View File

@ -1,24 +1,27 @@
{ lib {
, buildPythonPackage lib,
, fetchFromGitHub fetchFromGitHub,
, oldest-supported-numpy oldest-supported-numpy,
, numpy numpy,
, setuptools pypaBuildHook,
}: buildPythonPackage rec { pypaInstallHook,
setuptools,
stdenv,
}: stdenv.mkDerivation (finalAttrs: {
pname = "fastcluster"; pname = "fastcluster";
version = "1.2.6"; version = "1.2.6";
format = "pyproject";
# format = "setuptools";
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "fastcluster"; owner = "fastcluster";
repo = "fastcluster"; repo = "fastcluster";
rev = "v${version}"; rev = "v${finalAttrs.version}";
hash = "sha256-8FDipkAcOAI5zAC7JaJExe6HO1xHg+eXAL7IUIVrA3k="; hash = "sha256-8FDipkAcOAI5zAC7JaJExe6HO1xHg+eXAL7IUIVrA3k=";
}; };
nativeBuildInputs = [ nativeBuildInputs = [
oldest-supported-numpy oldest-supported-numpy
pypaBuildHook
pypaInstallHook
setuptools setuptools
]; ];
@ -35,4 +38,4 @@
description = "fast hierarchical clustering routines for R and Python"; description = "fast hierarchical clustering routines for R and Python";
maintainers = with maintainers; [ colinsane ]; maintainers = with maintainers; [ colinsane ];
}; };
} })

View File

@ -1,22 +1,24 @@
{ lib {
, buildPythonPackage lib,
, fetchFromGitHub fetchFromGitHub,
pypaBuildHook,
pypaInstallHook,
stdenv,
# nativeBuildInputs python packages # nativeBuildInputs python packages
, poetry-core poetry-core,
# propagatedBuildInputs python packages # propagatedBuildInputs python packages
, aiodns aiodns,
, aiohttp aiohttp,
, beautifulsoup4 beautifulsoup4,
, brotlipy brotlipy,
, cchardet cchardet,
, feedparser feedparser,
, python-dateutil python-dateutil,
, uvloop uvloop,
, w3lib w3lib,
, yarl yarl,
}: }:
stdenv.mkDerivation {
buildPythonPackage rec {
pname = "feedsearch-crawler"; pname = "feedsearch-crawler";
version = "2022-05-28"; version = "2022-05-28";
format = "pyproject"; format = "pyproject";
@ -34,10 +36,6 @@ buildPythonPackage rec {
./0001-response-chunk-size.patch ./0001-response-chunk-size.patch
]; ];
nativeBuildInputs = [
poetry-core
];
postPatch = '' postPatch = ''
substituteInPlace pyproject.toml \ substituteInPlace pyproject.toml \
--replace-fail 'w3lib = "^1.22.0"' 'w3lib = "*"' \ --replace-fail 'w3lib = "^1.22.0"' 'w3lib = "*"' \
@ -45,6 +43,12 @@ buildPythonPackage rec {
--replace-fail 'uvloop = "^0.15.2"' 'uvloop = "*"' --replace-fail 'uvloop = "^0.15.2"' 'uvloop = "*"'
''; '';
nativeBuildInputs = [
poetry-core
pypaBuildHook
pypaInstallHook
];
propagatedBuildInputs = [ propagatedBuildInputs = [
aiodns aiodns
aiohttp aiohttp

View File

@ -9,50 +9,46 @@
pytestCheckHook, pytestCheckHook,
requests, requests,
stdenv, stdenv,
toPythonModule,
}: }:
stdenv.mkDerivation (finalAttrs: {
pname = "listparser";
version = "0.20";
toPythonModule ( src = fetchFromGitHub {
stdenv.mkDerivation (finalAttrs: { owner = "kurtmckee";
pname = "listparser"; repo = "listparser";
version = "0.20"; rev = "v${finalAttrs.version}";
hash = "sha256-eg9TrjDgvHsYt/0JQ7MK/uGc3KK3uGr3jRxzG0FlySg=";
};
src = fetchFromGitHub { nativeBuildInputs = [
owner = "kurtmckee"; poetry-core
repo = "listparser"; pypaBuildHook
rev = "v${finalAttrs.version}"; pypaInstallHook
hash = "sha256-eg9TrjDgvHsYt/0JQ7MK/uGc3KK3uGr3jRxzG0FlySg="; ];
};
nativeBuildInputs = [ propagatedBuildInputs = [
poetry-core requests
pypaBuildHook lxml
pypaInstallHook ];
];
propagatedBuildInputs = [ nativeCheckInputs = [
requests pytestCheckHook
lxml ];
];
nativeCheckInputs = [ pythonImportsCheck = [
pytestCheckHook "listparser"
]; ];
pythonImportsCheck = [ doCheck = true;
"listparser"
];
doCheck = true; passthru.updateScript = nix-update-script { };
passthru.updateScript = nix-update-script { }; meta = with lib; {
description = "Parse OPML subscription lists in Python";
meta = with lib; { homepage = "https://github.com/kurtmckee/listparser";
description = "Parse OPML subscription lists in Python"; license = licenses.lgpl3Plus;
homepage = "https://github.com/kurtmckee/listparser"; maintainers = [ maintainers.colinsane ];
license = licenses.lgpl3Plus; platforms = platforms.linux;
maintainers = [ maintainers.colinsane ]; };
platforms = platforms.linux; })
};
})
)

View File

@ -1,19 +1,22 @@
{ lib {
, buildPythonPackage lib,
, fetchFromGitea buildPythonPackage,
, aiohttp fetchFromGitea,
, fastcluster aiohttp,
, fastjsonschema fastcluster,
, mercantile fastjsonschema,
, numpy mercantile,
, scipy numpy,
, setuptools pypaBuildHook,
pypaInstallHook,
scipy,
setuptools,
stdenv,
# , wheel # , wheel
}: buildPythonPackage { }: stdenv.mkDerivation {
pname = "ols"; pname = "ols";
version = "0.1.0-unstable-2024-06-21"; version = "0.1.0-unstable-2024-06-21";
format = "pyproject"; format = "pyproject";
# format = "setuptools";
src = fetchFromGitea { src = fetchFromGitea {
# my dev branch has a few changes: # my dev branch has a few changes:
@ -44,6 +47,8 @@
]; ];
nativeBuildInputs = [ nativeBuildInputs = [
pypaBuildHook
pypaInstallHook
setuptools setuptools
# wheel # wheel
]; ];

View File

@ -1,13 +1,16 @@
{ lib {
, buildPythonPackage lib,
, fetchFromGitLab fetchFromGitLab,
, flit-core flit-core,
, libpulseaudio libpulseaudio,
, psutil pypaBuildHook,
, pulseaudio pypaInstallHook,
psutil,
pulseaudio,
stdenv,
}: }:
buildPythonPackage rec { stdenv.mkDerivation (finalAttrs: {
pname = "pa-dlna"; pname = "pa-dlna";
version = "0.7"; version = "0.7";
format = "pyproject"; format = "pyproject";
@ -15,7 +18,7 @@ buildPythonPackage rec {
src = fetchFromGitLab { src = fetchFromGitLab {
owner = "xdegaye"; owner = "xdegaye";
repo = "pa-dlna"; repo = "pa-dlna";
rev = "v${version}"; rev = "v${finalAttrs.version}";
hash = "sha256-tc3AjxTMeLH82d8R95xsqLeAH1t/orW7c9DGjBwDWaU="; hash = "sha256-tc3AjxTMeLH82d8R95xsqLeAH1t/orW7c9DGjBwDWaU=";
}; };
@ -27,6 +30,8 @@ buildPythonPackage rec {
nativeBuildInputs = [ nativeBuildInputs = [
flit-core flit-core
pypaBuildHook
pypaInstallHook
]; ];
propagatedBuildInputs = [ propagatedBuildInputs = [
@ -48,4 +53,4 @@ buildPythonPackage rec {
license = licenses.mit; license = licenses.mit;
maintainers = with maintainers; [ colinsane ]; maintainers = with maintainers; [ colinsane ];
}; };
} })

View File

@ -1,7 +1,16 @@
# based on: <https://github.com/fort-nix/nix-bitcoin/blob/master/pkgs/python-packages/pyln-bolt7/default.nix> # based on: <https://github.com/fort-nix/nix-bitcoin/blob/master/pkgs/python-packages/pyln-bolt7/default.nix>
{ buildPythonPackage, poetry-core, pytestCheckHook, clightning, pyln-proto }: {
buildPythonPackage,
buildPythonPackage { clightning,
poetry-core,
pyln-proto,
pypaBuildHook,
pypaInstallHook,
pytestCheckHook,
stdenv,
unzip,
}:
stdenv.mkDerivation {
pname = "pyln-bolt7"; pname = "pyln-bolt7";
# the version is defined here: # the version is defined here:
# - <https://github.com/ElementsProject/lightning/blob/master/contrib/pyln-spec/bolt7/pyproject.toml> # - <https://github.com/ElementsProject/lightning/blob/master/contrib/pyln-spec/bolt7/pyproject.toml>
@ -10,13 +19,18 @@ buildPythonPackage {
# - `dtrx ./result` # - `dtrx ./result`
# - `rg version <extracted>/clightning-v23.11.2/contrib/pyln-spec/bolt7/pyproject.toml` # - `rg version <extracted>/clightning-v23.11.2/contrib/pyln-spec/bolt7/pyproject.toml`
version = "1.0.4.246"; version = "1.0.4.246";
format = "pyproject";
inherit (clightning) src; inherit (clightning) src;
nativeBuildInputs = [ poetry-core ];
propagatedBuildInputs = [ pyln-proto ];
checkInputs = [ pytestCheckHook ];
sourceRoot = "clightning-v${clightning.version}/contrib/pyln-spec/bolt7"; sourceRoot = "clightning-v${clightning.version}/contrib/pyln-spec/bolt7";
nativeBuildInputs = [
poetry-core
pypaBuildHook
pypaInstallHook
unzip # used by `unpackPhase`
];
propagatedBuildInputs = [
pyln-proto
];
nativeCheckInputs = [ pytestCheckHook ];
} }

View File

@ -1,20 +1,33 @@
# based on: <https://github.com/fort-nix/nix-bitcoin/blob/master/pkgs/python-packages/pyln-client/default.nix> # based on: <https://github.com/fort-nix/nix-bitcoin/blob/master/pkgs/python-packages/pyln-client/default.nix>
{ buildPythonPackage, poetry-core, pytestCheckHook, clightning, pyln-bolt7, pyln-proto }: {
clightning,
buildPythonPackage { poetry-core,
pyln-bolt7,
pyln-proto,
pypaBuildHook,
pypaInstallHook,
pytestCheckHook,
stdenv,
unzip,
}:
stdenv.mkDerivation {
pname = "pyln-client"; pname = "pyln-client";
format = "pyproject"; format = "pyproject";
inherit (clightning) src version; inherit (clightning) src version;
sourceRoot = "clightning-v${clightning.version}/contrib/pyln-client";
nativeBuildInputs = [ poetry-core ]; nativeBuildInputs = [
poetry-core
pypaBuildHook
pypaInstallHook
unzip # used by `unpackPhase`
];
propagatedBuildInputs = [ propagatedBuildInputs = [
pyln-bolt7 pyln-bolt7
pyln-proto pyln-proto
]; ];
checkInputs = [ pytestCheckHook ]; nativeCheckInputs = [ pytestCheckHook ];
sourceRoot = "clightning-v${clightning.version}/contrib/pyln-client";
} }

View File

@ -1,16 +1,21 @@
# based on: <https://github.com/fort-nix/nix-bitcoin/blob/master/pkgs/python-packages/pyln-proto/default.nix> # based on: <https://github.com/fort-nix/nix-bitcoin/blob/master/pkgs/python-packages/pyln-proto/default.nix>
{ buildPythonPackage {
, clightning clightning,
, poetry-core poetry-core,
, pytestCheckHook pypaBuildHook,
, bitstring pypaInstallHook,
, cryptography pytestCheckHook,
, coincurve stdenv,
, base58 unzip,
, pysocks # python runtime deps
base58,
bitstring,
coincurve,
cryptography,
pysocks,
}: }:
buildPythonPackage { stdenv.mkDerivation {
pname = "pyln-proto"; pname = "pyln-proto";
format = "pyproject"; format = "pyproject";
@ -25,7 +30,12 @@ buildPythonPackage {
--replace-fail 'cryptography = "^41"' 'cryptography = ">=41"' --replace-fail 'cryptography = "^41"' 'cryptography = ">=41"'
''; '';
nativeBuildInputs = [ poetry-core ]; nativeBuildInputs = [
poetry-core
pypaBuildHook
pypaInstallHook
unzip # used by `unpackPhase`
];
propagatedBuildInputs = [ propagatedBuildInputs = [
bitstring bitstring
@ -35,5 +45,5 @@ buildPythonPackage {
pysocks pysocks
]; ];
checkInputs = [ pytestCheckHook ]; nativeCheckInputs = [ pytestCheckHook ];
} }

View File

@ -1,28 +1,42 @@
{ lib {
, buildPythonPackage lib,
, fetchFromGitHub fetchFromGitHub,
}: buildPythonPackage { # pypaBuildHook,
pname = "mypackage"; # pypaInstallHook,
version = "0.1-unstable-2024-06-04"; pytestCheckHook,
format = "pyproject"; # or setuptools stdenv,
}: stdenv.mkDerivation (finalAttrs: {
# pname = "mypackage";
# version = "0.1-unstable-2024-06-04";
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "owner"; # owner = "owner";
repo = "repo"; # repo = "repo";
rev = "${version}"; rev = "v${finalAttrs.version}";
# hash = "";
}; };
nativeBuildInputs = [
# poetry-core
# pypaBuildHook
# pypaInstallHook
];
propagatedBuildInputs = [ propagatedBuildInputs = [
# other python modules this depends on, if this package is supposed to be importable # other python modules this depends on, if this package is supposed to be importable
]; ];
nativeCheckInputs = [
# pytestCheckHook
];
pythonImportsCheck = [ pythonImportsCheck = [
"mymodule" # "mymodule"
]; ];
meta = with lib; { meta = with lib; {
homepage = "https://example.com"; # homepage = "https://example.com";
description = "python template project"; # description = "python template project";
maintainers = with maintainers; [ colinsane ]; maintainers = with maintainers; [ colinsane ];
}; };
} })