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