1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5
6 # propagates
7 chardet,
8 regex,
9 packaging,
10
11 # optionals
12 faust-cchardet,
13 pandas,
14 tabview,
15 # TODO: , wilderness
16
17 # tests
18 python,
19 pytestCheckHook,
20}:
21
22buildPythonPackage rec {
23 pname = "clevercsv";
24 version = "0.8.2";
25 format = "setuptools";
26
27 src = fetchFromGitHub {
28 owner = "alan-turing-institute";
29 repo = "CleverCSV";
30 rev = "refs/tags/v${version}";
31 hash = "sha256-yyPUNFDq9W5OW1muHtQ10QgAHhXI8w7CY77fsWhIy0k=";
32 };
33
34 propagatedBuildInputs = [
35 chardet
36 regex
37 packaging
38 ];
39
40 passthru.optional-dependencies = {
41 full = [
42 faust-cchardet
43 pandas
44 tabview
45 # TODO: wilderness
46 ];
47 };
48
49 nativeCheckInputs = [ pytestCheckHook ] ++ passthru.optional-dependencies.full;
50
51 pythonImportsCheck = [
52 "clevercsv"
53 "clevercsv.cparser"
54 ];
55
56 preCheck = ''
57 # by linking the installed version the tests also have access to compiled native libraries
58 rm -r clevercsv
59 ln -s $out/${python.sitePackages}/clevercsv/ clevercsv
60 '';
61
62 # their ci only runs unit tests, there are also integration and fuzzing tests
63 pytestFlagsArray = [ "./tests/test_unit" ];
64
65 disabledTestPaths = [
66 # ModuleNotFoundError: No module named 'wilderness'
67 "tests/test_unit/test_console.py"
68 ];
69
70 meta = with lib; {
71 description = "CleverCSV is a Python package for handling messy CSV files";
72 mainProgram = "clevercsv";
73 longDescription = ''
74 CleverCSV is a Python package for handling messy CSV files. It provides
75 a drop-in replacement for the builtin CSV module with improved dialect
76 detection, and comes with a handy command line application for working
77 with CSV files.
78 '';
79 homepage = "https://github.com/alan-turing-institute/CleverCSV";
80 changelog = "https://github.com/alan-turing-institute/CleverCSV/blob/${src.rev}/CHANGELOG.md";
81 license = licenses.mit;
82 maintainers = with maintainers; [ hexa ];
83 };
84}