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;
unpatched = pkgs;
pythonPackagesOverlayFor = pkgs: py-final: py-prev: import ./python-packages {
inherit (py-final) callPackage;
pythonPackagesOverlayFor = pkgs: pyFinal: _pyPrev: import ./python-packages {
inherit (pyFinal) callPackage toPythonModule;
inherit pkgs;
};
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 { };
feedsearch-crawler = callPackage ./feedsearch-crawler { };
fastcluster = callPackage ./fastcluster { };
listparser = callPackage ./listparser { };
ols = callPackage ./ols { };
pa-dlna = callPackage ./pa-dlna { };
pyln-bolt7 = callPackage ./pyln-bolt7 { };
pyln-client = callPackage ./pyln-client { };
pyln-proto = callPackage ./pyln-proto { };
depthcharge-tools = toPythonModule (callPackage ./depthcharge-tools { });
feedsearch-crawler = toPythonModule (callPackage ./feedsearch-crawler { });
fastcluster = toPythonModule (callPackage ./fastcluster { });
listparser = toPythonModule (callPackage ./listparser { });
ols = toPythonModule (callPackage ./ols { });
pa-dlna = toPythonModule (callPackage ./pa-dlna { });
pyln-bolt7 = toPythonModule (callPackage ./pyln-bolt7 { });
pyln-client = toPythonModule (callPackage ./pyln-client { });
pyln-proto = toPythonModule (callPackage ./pyln-proto { });
sane-lib = pkgs.sane-scripts.lib;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,13 +1,16 @@
{ lib
, buildPythonPackage
, fetchFromGitLab
, flit-core
, libpulseaudio
, psutil
, pulseaudio
{
lib,
fetchFromGitLab,
flit-core,
libpulseaudio,
pypaBuildHook,
pypaInstallHook,
psutil,
pulseaudio,
stdenv,
}:
buildPythonPackage rec {
stdenv.mkDerivation (finalAttrs: {
pname = "pa-dlna";
version = "0.7";
format = "pyproject";
@ -15,7 +18,7 @@ buildPythonPackage rec {
src = fetchFromGitLab {
owner = "xdegaye";
repo = "pa-dlna";
rev = "v${version}";
rev = "v${finalAttrs.version}";
hash = "sha256-tc3AjxTMeLH82d8R95xsqLeAH1t/orW7c9DGjBwDWaU=";
};
@ -27,6 +30,8 @@ buildPythonPackage rec {
nativeBuildInputs = [
flit-core
pypaBuildHook
pypaInstallHook
];
propagatedBuildInputs = [
@ -48,4 +53,4 @@ buildPythonPackage rec {
license = licenses.mit;
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>
{ buildPythonPackage, poetry-core, pytestCheckHook, clightning, pyln-proto }:
buildPythonPackage {
{
buildPythonPackage,
clightning,
poetry-core,
pyln-proto,
pypaBuildHook,
pypaInstallHook,
pytestCheckHook,
stdenv,
unzip,
}:
stdenv.mkDerivation {
pname = "pyln-bolt7";
# the version is defined here:
# - <https://github.com/ElementsProject/lightning/blob/master/contrib/pyln-spec/bolt7/pyproject.toml>
@ -10,13 +19,18 @@ buildPythonPackage {
# - `dtrx ./result`
# - `rg version <extracted>/clightning-v23.11.2/contrib/pyln-spec/bolt7/pyproject.toml`
version = "1.0.4.246";
format = "pyproject";
inherit (clightning) src;
nativeBuildInputs = [ poetry-core ];
propagatedBuildInputs = [ pyln-proto ];
checkInputs = [ pytestCheckHook ];
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>
{ buildPythonPackage, poetry-core, pytestCheckHook, clightning, pyln-bolt7, pyln-proto }:
buildPythonPackage {
{
clightning,
poetry-core,
pyln-bolt7,
pyln-proto,
pypaBuildHook,
pypaInstallHook,
pytestCheckHook,
stdenv,
unzip,
}:
stdenv.mkDerivation {
pname = "pyln-client";
format = "pyproject";
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 = [
pyln-bolt7
pyln-proto
];
checkInputs = [ pytestCheckHook ];
sourceRoot = "clightning-v${clightning.version}/contrib/pyln-client";
nativeCheckInputs = [ pytestCheckHook ];
}

View File

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

View File

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