1{ lib, stdenv
2, buildPythonPackage
3, isPy27
4, fetchPypi
5, enchant2
6}:
7
8buildPythonPackage rec {
9 pname = "pyenchant";
10 version = "3.2.2";
11 disabled = isPy27;
12
13 src = fetchPypi {
14 inherit pname version;
15 sha256 = "1cf830c6614362a78aab78d50eaf7c6c93831369c52e1bb64ffae1df0341e637";
16 };
17
18 propagatedBuildInputs = [ enchant2 ];
19
20 postPatch = let
21 libext = stdenv.hostPlatform.extensions.sharedLibrary;
22 in ''
23 # Use the $PYENCHANT_LIBRARY_PATH envvar lookup line to hard-code the
24 # location of the nix enchant-2 library into _enchant.py.
25 #
26 # Also, they hardcode a bad path for Darwin in their library search code;
27 # This code should never be hit, but in case it does, we don't want to have
28 # it "accidentally" work by pulling something from /opt.
29 substituteInPlace enchant/_enchant.py \
30 --replace 'os.environ.get("PYENCHANT_LIBRARY_PATH")' \
31 "'${enchant2}/lib/libenchant-2${libext}'" \
32 --replace '/opt/local/lib/' ""
33 '';
34
35 # dictionaries needed for tests
36 doCheck = false;
37
38 meta = with lib; {
39 description = "pyenchant: Python bindings for the Enchant spellchecker";
40 homepage = "https://github.com/pyenchant/pyenchant";
41 license = licenses.lgpl21;
42 };
43
44}