diff --git a/pkgs/development/python-modules/pystemmer/default.nix b/pkgs/development/python-modules/pystemmer/default.nix index 120867f389cc..dd258c380c6f 100644 --- a/pkgs/development/python-modules/pystemmer/default.nix +++ b/pkgs/development/python-modules/pystemmer/default.nix @@ -1,22 +1,69 @@ -{ lib, python, fetchPypi, buildPythonPackage, cython }: +{ lib +, python +, fetchPypi +, fetchFromGitHub +, fetchpatch +, buildPythonPackage +, cython +, libstemmer + }: buildPythonPackage rec { pname = "PyStemmer"; - version = "2.0.1"; + version = "2.2.0"; + format = "setuptools"; - src = fetchPypi { + src' = fetchPypi { inherit pname version; - sha256 = "9b81c35302f1d2a5ad9465b85986db246990db93d97d3e8f129269ed7102788e"; + sha256 = "sha256-4hcbkbhrscap3d8J6Mhn5Ij4vWm94H0EEKNc3O4NhXw="; + }; + + src = fetchFromGitHub { + owner = "snowballstem"; + repo = "pystemmer"; + rev = "refs/tags/v${version}"; + hash = "sha256-bJVFeO7XP+aZ2nowQiuws5ziL/FmS1eaOllW6QxA70U="; }; nativeBuildInputs = [ cython ]; - preBuild = '' - cython src/Stemmer.pyx + 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; {