1{
2 lib,
3 buildPythonPackage,
4 fetchPypi,
5 fetchpatch,
6
7 # build-system
8 hatchling,
9
10 # docs
11 sphinxHook,
12
13 # dependencies
14 soupsieve,
15 typing-extensions,
16
17 # optional-dependencies
18 chardet,
19 charset-normalizer,
20 faust-cchardet,
21 html5lib,
22 lxml,
23
24 # tests
25 pytestCheckHook,
26
27 # for passthru.tests
28 html-sanitizer,
29 markdownify,
30 mechanicalsoup,
31 nbconvert,
32 subliminal,
33 wagtail,
34}:
35
36buildPythonPackage rec {
37 pname = "beautifulsoup4";
38 version = "4.13.4";
39 pyproject = true;
40
41 outputs = [
42 "out"
43 "doc"
44 ];
45
46 src = fetchPypi {
47 inherit pname version;
48 hash = "sha256-27PE4c6uau/r2vJCMkcmDNBiQwpBDjjGbyuqUKhDcZU=";
49 };
50
51 patches = [
52 # backport test fix for behavior changes in libxml 2.14.3
53 (fetchpatch {
54 url = "https://git.launchpad.net/beautifulsoup/patch/?id=53d328406ec8c37c0edbd00ace3782be63e2e7e5";
55 excludes = [ "CHANGELOG" ];
56 hash = "sha256-RtavbpnfT6x0A8L3tAvCXwKUpty1ASPGJKdks7evBr8=";
57 })
58 ];
59
60 build-system = [ hatchling ];
61
62 nativeBuildInputs = [ sphinxHook ];
63
64 dependencies = [
65 soupsieve
66 typing-extensions
67 ];
68
69 optional-dependencies = {
70 chardet = [ chardet ];
71 cchardet = [ faust-cchardet ];
72 charset-normalizer = [ charset-normalizer ];
73 html5lib = [ html5lib ];
74 lxml = [ lxml ];
75 };
76
77 nativeCheckInputs = [
78 pytestCheckHook
79 ]
80 ++ lib.flatten (lib.attrValues optional-dependencies);
81
82 disabledTests = [
83 # fail with latest libxml, by not actually rejecting
84 "test_rejected_markup"
85 "test_rejected_input"
86 ];
87
88 pythonImportsCheck = [ "bs4" ];
89
90 passthru.tests = {
91 inherit
92 html-sanitizer
93 markdownify
94 mechanicalsoup
95 nbconvert
96 subliminal
97 wagtail
98 ;
99 };
100
101 meta = with lib; {
102 changelog = "https://git.launchpad.net/beautifulsoup/tree/CHANGELOG?h=${version}";
103 description = "HTML and XML parser";
104 homepage = "http://crummy.com/software/BeautifulSoup/bs4/";
105 license = licenses.mit;
106 maintainers = with maintainers; [ ];
107 };
108}