1{ lib 2, python 3, fetchPypi 4, fetchFromGitHub 5, fetchpatch 6, buildPythonPackage 7, cython 8, libstemmer 9 }: 10 11buildPythonPackage rec { 12 pname = "pystemmer"; 13 version = "2.2.0"; 14 format = "setuptools"; 15 16 src = fetchFromGitHub { 17 owner = "snowballstem"; 18 repo = "pystemmer"; 19 rev = "refs/tags/v${version}"; 20 hash = "sha256-bJVFeO7XP+aZ2nowQiuws5ziL/FmS1eaOllW6QxA70U="; 21 }; 22 23 nativeBuildInputs = [ cython ]; 24 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 ]; 37 38 postConfigure = '' 39 export PYSTEMMER_SYSTEM_LIBSTEMMER="${lib.getDev libstemmer}/include" 40 ''; 41 42 env.NIX_CFLAGS_COMPILE = toString [ 43 "-I${lib.getDev libstemmer}/include" 44 ]; 45 46 NIX_CFLAGS_LINK = [ 47 "-L${libstemmer}/lib" 48 ]; 49 50 pythonImportsCheck = [ 51 "Stemmer" 52 ]; 53 54 checkPhase = '' 55 runHook preCheck 56 ${python.interpreter} runtests.py 57 runHook postCheck 58 ''; 59 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 }; 66}