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