about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeder Bergebakken Sundt <pbsds@hotmail.com>2024-09-27 11:27:57 +0200
committerGitHub <noreply@github.com>2024-09-27 11:27:57 +0200
commitfdadb5f0df5d2641c7e4494f4defc31f1e9cb8c0 (patch)
treee358b9a09eaf4ca22b2cc9cde85a7d198df8983c
parenta26c20910e1d1ad5e07b7d0f094e34c6e29ebeb9 (diff)
parent13bc6217b95036579018fb747a480f9f2921de94 (diff)
python312Packages.cltk: modernize and fix build (#344745)
-rw-r--r--pkgs/development/python-modules/cltk/default.nix83
1 files changed, 55 insertions, 28 deletions
diff --git a/pkgs/development/python-modules/cltk/default.nix b/pkgs/development/python-modules/cltk/default.nix
index c1f88ddfa3267..7635ace28648e 100644
--- a/pkgs/development/python-modules/cltk/default.nix
+++ b/pkgs/development/python-modules/cltk/default.nix
@@ -1,31 +1,42 @@
 {
-  buildPythonPackage,
   lib,
-  fetchPypi,
-  gitpython,
-  gensim,
-  tqdm,
-  torch,
-  stringcase,
-  stanza,
-  spacy,
-  scipy,
-  scikit-learn,
-  requests,
-  rapidfuzz,
-  pyyaml,
-  nltk,
-  boltons,
+  buildPythonPackage,
+  fetchFromGitHub,
+
+  # build-system
   poetry-core,
+
+  # dependencies
+  boltons,
+  gensim,
+  gitpython,
   greek-accentuation,
+  nltk,
+  pyyaml,
+  rapidfuzz,
+  requests,
+  scikit-learn,
+  scipy,
+  spacy,
+  stanza,
+  stringcase,
+  torch,
+  tqdm,
+
+  # tests
+  pytestCheckHook,
 }:
 buildPythonPackage rec {
   pname = "cltk";
-  format = "pyproject";
   version = "1.3.0";
-  src = fetchPypi {
-    inherit pname version;
-    hash = "sha256-jAxvToUIo333HSVQDYVyUBY3YP+m1RnlNGelcvktp6s=";
+
+  pyproject = true;
+
+  src = fetchFromGitHub {
+    owner = "cltk";
+    repo = "cltk";
+    rev = "refs/tags/v${version}";
+    hash = "sha256-/rdv96lnSGN+aJJmPSIan79zoXxnStokFEAjBtCLKy4=";
   };
 
   postPatch = ''
@@ -36,13 +47,19 @@ buildPythonPackage rec {
       --replace-fail 'boltons = "^21.0.0"' 'boltons = "^24.0.0"'
   '';
 
-  propagatedBuildInputs = [
-    gitpython
-    gensim
+  build-system = [ poetry-core ];
+
+  pythonRelaxDeps = [
+    "spacy"
+  ];
+
+  dependencies = [
     boltons
+    gensim
+    gitpython
     greek-accentuation
-    pyyaml
     nltk
+    pyyaml
     rapidfuzz
     requests
     scikit-learn
@@ -54,12 +71,22 @@ buildPythonPackage rec {
     tqdm
   ];
 
-  nativeBuildInputs = [ poetry-core ];
+  nativeCheckInputs = [
+    pytestCheckHook
+  ];
+
+  preCheck = ''
+    export HOME=$(mktemp -d)
+  '';
+
+  # Most of tests fail as they require local files to be present and also internet access
+  doCheck = false;
 
-  meta = with lib; {
+  meta = {
     description = "Natural language processing (NLP) framework for pre-modern languages";
     homepage = "https://cltk.org";
-    license = licenses.mit;
-    maintainers = with maintainers; [ kmein ];
+    changelog = "https://github.com/cltk/cltk/releases/tag/v${version}";
+    license = lib.licenses.mit;
+    maintainers = with lib.maintainers; [ kmein ];
   };
 }