1{
2 lib,
3 buildPythonPackage,
4 ddt,
5 fetchFromGitHub,
6 importlib-metadata,
7 jsonschema,
8 license-expression,
9 lxml,
10 packageurl-python,
11 py-serializable,
12 poetry-core,
13 pytestCheckHook,
14 pythonOlder,
15 requirements-parser,
16 sortedcontainers,
17 setuptools,
18 toml,
19 types-setuptools,
20 types-toml,
21 xmldiff,
22}:
23
24buildPythonPackage rec {
25 pname = "cyclonedx-python-lib";
26 version = "7.5.0";
27 pyproject = true;
28
29 disabled = pythonOlder "3.9";
30
31 src = fetchFromGitHub {
32 owner = "CycloneDX";
33 repo = "cyclonedx-python-lib";
34 rev = "refs/tags/v${version}";
35 hash = "sha256-yBBtE9DfHzUNXHMCo3KoUAAsvkBshczmVtMCUTtQ9zg=";
36 };
37
38 pythonRelaxDeps = [ "py-serializable" ];
39
40 build-system = [ poetry-core ];
41
42 dependencies = [
43 importlib-metadata
44 license-expression
45 packageurl-python
46 requirements-parser
47 setuptools
48 sortedcontainers
49 toml
50 py-serializable
51 types-setuptools
52 types-toml
53 ];
54
55 passthru.optional-dependencies = {
56 validation = [
57 jsonschema
58 lxml
59 ];
60 json-validation = [
61 jsonschema
62 ];
63 xml-validation = [
64 lxml
65 ];
66 };
67
68 nativeCheckInputs = [
69 ddt
70 pytestCheckHook
71 xmldiff
72 ] ++ lib.flatten (builtins.attrValues passthru.optional-dependencies);
73
74 pythonImportsCheck = [ "cyclonedx" ];
75
76 preCheck = ''
77 export PYTHONPATH=tests''${PYTHONPATH+:$PYTHONPATH}
78 '';
79
80 pytestFlagsArray = [ "tests/" ];
81
82 disabledTests = [
83 # These tests require network access
84 "test_bom_v1_3_with_metadata_component"
85 "test_bom_v1_4_with_metadata_component"
86 # AssertionError: <ValidationError: "{'algorithm': 'ES256', ...
87 "TestJson"
88 ];
89
90 disabledTestPaths = [
91 # Test failures seem py-serializable related
92 "tests/test_output_xml.py"
93 ];
94
95 meta = with lib; {
96 description = "Python library for generating CycloneDX SBOMs";
97 homepage = "https://github.com/CycloneDX/cyclonedx-python-lib";
98 changelog = "https://github.com/CycloneDX/cyclonedx-python-lib/releases/tag/v${version}";
99 license = with licenses; [ asl20 ];
100 maintainers = with maintainers; [ fab ];
101 };
102}