Merge pull request #268619 from tweag/lib-descriptions
[NixPkgs.git] / pkgs / development / python-modules / pystemmer / default.nix
blob0df510e0b55db5a244bea352aa092745ad1d5656
1 { lib
2 , python
3 , fetchPypi
4 , fetchFromGitHub
5 , fetchpatch
6 , buildPythonPackage
7 , cython
8 , libstemmer
9  }:
11 buildPythonPackage rec {
12   pname = "pystemmer";
13   version = "2.2.0";
14   format = "setuptools";
16   src = fetchFromGitHub {
17     owner = "snowballstem";
18     repo = "pystemmer";
19     rev = "refs/tags/v${version}";
20     hash = "sha256-bJVFeO7XP+aZ2nowQiuws5ziL/FmS1eaOllW6QxA70U=";
21   };
23   nativeBuildInputs = [ cython ];
25   patches = [
26     (fetchpatch {
27       # Allow building with system libstemmer
28       url = "https://github.com/snowballstem/pystemmer/commit/2f52b4b2ff113fe6c33cebe14ed4fd4388bb1742.patch";
29       hash = "sha256-JqR/DUmABgWaq23CNjoKSasL0mNhM2QuU986mouK6A8=";
30     })
31     (fetchpatch {
32       # Fix doctests
33       url = "https://github.com/snowballstem/pystemmer/commit/b2826f19fe8ba65238b5f3b4cee7096a698f048e.patch";
34       hash = "sha256-VTZydjYaJJ/KoHD4KbON36kZnkuAyO51H0Oeg6VXTqg=";
35     })
36   ];
38   postConfigure = ''
39     export PYSTEMMER_SYSTEM_LIBSTEMMER="${lib.getDev libstemmer}/include"
40   '';
42   env.NIX_CFLAGS_COMPILE = toString [
43     "-I${lib.getDev libstemmer}/include"
44   ];
46   NIX_CFLAGS_LINK = [
47     "-L${libstemmer}/lib"
48   ];
50   pythonImportsCheck = [
51     "Stemmer"
52   ];
54   checkPhase = ''
55     runHook preCheck
56     ${python.interpreter} runtests.py
57     runHook postCheck
58   '';
60   meta = with lib; {
61     description = "Snowball stemming algorithms, for information retrieval";
62     homepage = "http://snowball.tartarus.org/";
63     license = licenses.mit;
64     platforms = platforms.unix;
65   };