summary refs log tree commit diff
path: root/pkgs/development/python-modules/pystemmer/default.nix
blob: dd258c380c6f084814943d4b0e8aa0d1d3717eb8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
{ lib
, python
, fetchPypi
, fetchFromGitHub
, fetchpatch
, buildPythonPackage
, cython
, libstemmer
 }:

buildPythonPackage rec {
  pname = "PyStemmer";
  version = "2.2.0";
  format = "setuptools";

  src' = fetchPypi {
    inherit pname version;
    sha256 = "sha256-4hcbkbhrscap3d8J6Mhn5Ij4vWm94H0EEKNc3O4NhXw=";
  };

  src = fetchFromGitHub {
    owner = "snowballstem";
    repo = "pystemmer";
    rev = "refs/tags/v${version}";
    hash = "sha256-bJVFeO7XP+aZ2nowQiuws5ziL/FmS1eaOllW6QxA70U=";
  };

  nativeBuildInputs = [ cython ];

  patches = [
    (fetchpatch {
      # Allow building with system libstemmer
      url = "https://github.com/snowballstem/pystemmer/commit/2f52b4b2ff113fe6c33cebe14ed4fd4388bb1742.patch";
      hash = "sha256-JqR/DUmABgWaq23CNjoKSasL0mNhM2QuU986mouK6A8=";
    })
    (fetchpatch {
      # Fix doctests
      url = "https://github.com/snowballstem/pystemmer/commit/b2826f19fe8ba65238b5f3b4cee7096a698f048e.patch";
      hash = "sha256-VTZydjYaJJ/KoHD4KbON36kZnkuAyO51H0Oeg6VXTqg=";
    })
  ];

  postConfigure = ''
    export PYSTEMMER_SYSTEM_LIBSTEMMER="${lib.getDev libstemmer}/include"
  '';

  NIX_CFLAGS_COMPILE = [
    "-I${lib.getDev libstemmer}/include"
  ];

  NIX_CFLAGS_LINK = [
    "-L${libstemmer}/lib"
  ];

  #preBuild = ''
  #  cython src/Stemmer.pyx
  #'';

  pythonImportsCheck = [
    "Stemmer"
  ];

  checkPhase = ''
    runHook preCheck
    ${python.interpreter} runtests.py
    runHook postCheck
  '';

  meta = with lib; {
    description = "Snowball stemming algorithms, for information retrieval";
    homepage = "http://snowball.tartarus.org/";
    license = licenses.mit;
    platforms = platforms.unix;
  };
}