Repository navigation
Expand file tree
/
Copy path_inputs.py
More file actions
158 lines (118 loc) · 4.46 KB
/
Copy path_inputs.py
File metadata and controls
158 lines (118 loc) · 4.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
from __future__ import annotations
from dataclasses import dataclass, field
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from email.message import Message
from importlib.metadata import PackageMetadata
from pathlib import Path, PurePosixPath
from ._types import Component, Dependency, OrganizationalEntity, Property
@dataclass(frozen=True, slots=True, kw_only=True)
class RecordRow:
path: str
algorithm: str
digest: str
size: str
@dataclass(frozen=True, slots=True, kw_only=True)
class Interpreter:
name: str
version: str
implementation: str
@dataclass(frozen=True, slots=True, kw_only=True)
class InstalledDistribution:
name: str
metadata: PackageMetadata | Message
files: list[RecordRow]
depends_on: list[str]
@dataclass(frozen=True, slots=True, kw_only=True)
class Revision:
commit: str
dirty: bool
@dataclass(frozen=True, slots=True, kw_only=True)
class BuildFacts:
epoch: int
epoch_from_environment: bool
revision: Revision | None
interpreter: Interpreter
distributions: list[InstalledDistribution]
@dataclass(frozen=True, slots=True, kw_only=True)
class Settings:
"""
The project's options, from ``[tool.python-sbom]``.
:param supplier: the organization that supplies the project, or ``None`` to name none
:param repository: the repository URL, or ``None`` to take the first ``Source``, ``Repository`` or ``GitHub``
project URL
:param default_branch: the branch in links to files in the repository
:param bundled_wheels: glob patterns, relative to the project directory, of wheels the project ships as data files
:param content_provider: ``module:attribute`` of the content provider, or ``None``
"""
supplier: OrganizationalEntity | None
repository: str | None
default_branch: str
bundled_wheels: tuple[str, ...]
content_provider: str | None
@dataclass(frozen=True, slots=True, kw_only=True)
class SbomRequest:
root: Path
metadata: Message
wheel_name: str
settings: Settings
build_scripts: tuple[PurePosixPath, ...]
@dataclass(frozen=True, slots=True, kw_only=True)
class BundledWheel:
path: str
sha256: str
metadata_name: str
metadata: Message
files: list[RecordRow]
vendored: list[tuple[str, Message]]
@dataclass(frozen=True, slots=True, kw_only=True)
class BuildScript:
path: PurePosixPath
sha256: str
@dataclass(frozen=True, slots=True, kw_only=True)
class SourceTree:
copyright: str | None
bundled: list[BundledWheel]
build_scripts: list[BuildScript]
@dataclass(frozen=True, slots=True, kw_only=True)
class BundledWheelInfo:
"""
What a project adds to the component of one bundled wheel.
Both fields default to empty, so a provider names only what it adds.
:param properties: properties after ``<prefix>:bundled-wheel``, before those from the wheel's metadata
:param supplier: the wheel's supplier, or ``None`` to name none; only the project decides a bundled wheel's
supplier, never the wheel's own metadata
"""
properties: list[Property] = field(default_factory=list)
supplier: OrganizationalEntity | None = None
@dataclass(frozen=True, slots=True, kw_only=True)
class Contributions:
"""
What a project adds to the document beyond its bundled wheels, merged before references and the serial are derived.
Each field defaults to empty, so a provider names only what it adds. The build fails when a ``bom-ref`` repeats or
a dependency names one that does not exist.
:param components: extra top-level components, such as vendored C libraries; the root depends on each, and a
component's own parts nest under its ``components``
:param dependencies: extra dependency entries, such as the dependencies of those components
:param root_properties: extra properties of the root component; their names must not start with the project's
prefix, which python-sbom's own properties use
:param tools: extra build tools
"""
components: list[Component] = field(default_factory=list)
dependencies: list[Dependency] = field(default_factory=list)
root_properties: list[Property] = field(default_factory=list)
tools: list[Component] = field(default_factory=list)
__all__ = [
"BuildFacts",
"BuildScript",
"BundledWheel",
"BundledWheelInfo",
"Contributions",
"InstalledDistribution",
"Interpreter",
"RecordRow",
"Revision",
"SbomRequest",
"Settings",
"SourceTree",
]