1{ lib
2, stdenv
3, buildPythonPackage
4, fetchPypi
5, python
6, nose
7}:
8
9buildPythonPackage rec {
10 pname = "cchardet";
11 version = "2.1.7";
12
13 src = fetchPypi {
14 inherit pname version;
15 sha256 = "c428b6336545053c2589f6caf24ea32276c6664cb86db817e03a94c60afa0eaf";
16 };
17
18 pythonImportsCheck = [
19 "cchardet"
20 ];
21
22 checkInputs = [ nose ];
23
24 # on non x86-64 some charsets are identified as their superset, so we skip these tests (last checked with version 2.1.7)
25 preCheck = ''
26 cp -R src/tests $TMPDIR
27 pushd $TMPDIR
28 '' + lib.optionalString (stdenv.hostPlatform.system != "x86_64-linux") ''
29 rm $TMPDIR/tests/testdata/th/tis-620.txt # identified as iso-8859-11, which is fine for all practical purposes
30 rm $TMPDIR/tests/testdata/ga/iso-8859-1.txt # identified as windows-1252, which is fine for all practical purposes
31 rm $TMPDIR/tests/testdata/fi/iso-8859-1.txt # identified as windows-1252, which is fine for all practical purposes
32 '';
33
34 checkPhase = ''
35 runHook preCheck
36
37 nosetests
38
39 runHook postCheck
40 '';
41
42 postCheck = ''
43 popd
44 '';
45
46 meta = {
47 description = "High-speed universal character encoding detector";
48 homepage = "https://github.com/PyYoshi/cChardet";
49 license = lib.licenses.mpl11;
50 maintainers = with lib.maintainers; [ ivan ];
51 };
52}