Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 fetchpatch,
6 setuptools,
7 python-dateutil,
8 pytz,
9 regex,
10 tzlocal,
11 hijridate,
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.2";
26
27 pyproject = true;
28
29 src = fetchFromGitHub {
30 owner = "scrapinghub";
31 repo = "dateparser";
32 tag = "v${version}";
33 hash = "sha256-cUbY6c0JFzs1oZJOTnMXz3uCah2f50g8/3uWQXtwiGY=";
34 };
35
36 patches = [
37 (fetchpatch {
38 # https://github.com/scrapinghub/dateparser/pull/1294
39 url = "https://github.com/scrapinghub/dateparser/commit/6b23348b9367d43bebc9a40b00dda3363eb2acd5.patch";
40 hash = "sha256-LriRbGdYxF51Nwrm7Dp4kivyMikzmhytNQo0txMGsVI=";
41 })
42 (fetchpatch {
43 url = "https://github.com/scrapinghub/dateparser/commit/cbe29797c463c7939234df2923af310ed10aeb4f.patch";
44 includes = [ "dateparser_scripts/write_complete_data.py" ];
45 hash = "sha256-mDHDZlWU2G/NU2W+dxSRb6rRb/bp2PoTbgz8wXhaNCo=";
46 })
47 ];
48
49 nativeBuildInputs = [ setuptools ];
50
51 propagatedBuildInputs = [
52 python-dateutil
53 pytz
54 regex
55 tzlocal
56 ];
57
58 optional-dependencies = {
59 calendars = [
60 hijridate
61 convertdate
62 ];
63 fasttext = [ fasttext ];
64 langdetect = [ langdetect ];
65 };
66
67 nativeCheckInputs = [
68 parameterized
69 pytestCheckHook
70 gitpython
71 parsel
72 requests
73 ruamel-yaml
74 ]
75 ++ lib.concatAttrValues optional-dependencies;
76
77 preCheck = ''
78 export HOME="$TEMPDIR"
79 '';
80
81 # Upstream only runs the tests in tests/ in CI, others use git clone
82 enabledTestPaths = [ "tests" ];
83
84 disabledTests = [
85 # access network
86 "test_custom_language_detect_fast_text_0"
87 "test_custom_language_detect_fast_text_1"
88
89 # breaks with latest tzdata: https://github.com/scrapinghub/dateparser/issues/1237
90 # FIXME: look into this more
91 "test_relative_base"
92 ];
93
94 pythonImportsCheck = [ "dateparser" ];
95
96 meta = {
97 changelog = "https://github.com/scrapinghub/dateparser/blob/${src.tag}/HISTORY.rst";
98 description = "Date parsing library designed to parse dates from HTML pages";
99 homepage = "https://github.com/scrapinghub/dateparser";
100 license = lib.licenses.bsd3;
101 mainProgram = "dateparser-download";
102 maintainers = with lib.maintainers; [ dotlambda ];
103 };
104}