nixpkgs/pkgs/development/python-modules/pystemmer/default.nix
2023-01-05 01:10:23 +01:00

76 lines
1.6 KiB
Nix

{ 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;
};
}