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