1{
2 lib,
3 buildPythonPackage,
4 pythonOlder,
5 fetchFromGitHub,
6 setuptools,
7 python-dateutil,
8 pytz,
9 regex,
10 tzlocal,
11 hijri-converter,
12 convertdate,
13 fasttext,
14 langdetect,
15 parameterized,
16 pytestCheckHook,
17 gitpython,
18 parsel,
19 requests,
20 ruamel-yaml,
21}:
22
23buildPythonPackage rec {
24 pname = "dateparser";
25 version = "1.2.0";
26
27 disabled = pythonOlder "3.7";
28
29 pyproject = true;
30
31 src = fetchFromGitHub {
32 owner = "scrapinghub";
33 repo = "dateparser";
34 rev = "refs/tags/v${version}";
35 hash = "sha256-mnL44hojebOwP6qtEBHs5QM4uRmLuGlVNr+sM3jZEKE=";
36 };
37
38 nativeBuildInputs = [ setuptools ];
39
40 propagatedBuildInputs = [
41 python-dateutil
42 pytz
43 regex
44 tzlocal
45 ];
46
47 passthru.optional-dependencies = {
48 calendars = [
49 hijri-converter
50 convertdate
51 ];
52 fasttext = [ fasttext ];
53 langdetect = [ langdetect ];
54 };
55
56 nativeCheckInputs = [
57 parameterized
58 pytestCheckHook
59 gitpython
60 parsel
61 requests
62 ruamel-yaml
63 ] ++ lib.flatten (lib.attrValues passthru.optional-dependencies);
64
65 preCheck = ''
66 export HOME="$TEMPDIR"
67 '';
68
69 # Upstream only runs the tests in tests/ in CI, others use git clone
70 pytestFlagsArray = [ "tests" ];
71
72 disabledTests = [
73 # access network
74 "test_custom_language_detect_fast_text_0"
75 "test_custom_language_detect_fast_text_1"
76 ];
77
78 pythonImportsCheck = [ "dateparser" ];
79
80 meta = with lib; {
81 changelog = "https://github.com/scrapinghub/dateparser/blob/${src.rev}/HISTORY.rst";
82 description = "Date parsing library designed to parse dates from HTML pages";
83 homepage = "https://github.com/scrapinghub/dateparser";
84 license = licenses.bsd3;
85 mainProgram = "dateparser-download";
86 maintainers = with maintainers; [ dotlambda ];
87 };
88}