summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/pyenchant/default.nix
blob: 3ca3b126b8f3604f1a78058b514405fe5114fb47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
{
  lib,
  stdenv,
  buildPythonPackage,
  isPy27,
  fetchPypi,
  enchant_2,
}:

buildPythonPackage rec {
  pname = "pyenchant";
  version = "3.3.0";
  format = "setuptools";
  disabled = isPy27;

  src = fetchPypi {
    inherit pname version;
    sha256 = "sha256-glKIJGtd68lDb5GWdlCXTvDVY2RYUCYZ4yLEdvEoOJE=";
  };

  propagatedBuildInputs = [ enchant_2 ];

  postPatch =
    let
      libext = stdenv.hostPlatform.extensions.sharedLibrary;
    in
    ''
      # Use the $PYENCHANT_LIBRARY_PATH envvar lookup line to hard-code the
      # location of the nix enchant-2 library into _enchant.py.
      #
      # Also, they hardcode a bad path for Darwin in their library search code;
      # This code should never be hit, but in case it does, we don't want to have
      # it "accidentally" work by pulling something from /opt.
      substituteInPlace enchant/_enchant.py                  \
        --replace 'os.environ.get("PYENCHANT_LIBRARY_PATH")' \
                  "'${enchant_2}/lib/libenchant-2${libext}'"  \
        --replace '/opt/local/lib/' ""
    '';

  # dictionaries needed for tests
  doCheck = false;

  meta = {
    description = "Python bindings for the Enchant spellchecker";
    homepage = "https://github.com/pyenchant/pyenchant";
    license = lib.licenses.lgpl21;
  };
}