ssg.requirement_specs module
Common functions for processing Requirements Specs in SSG
- class ssg.requirement_specs.Requirement(obj: str)[source]
Bases:
objectA class to represent a package requirement with version specifications.
- _req
The parsed requirement object.
- Type:
- _specs
The set of version specifiers for the requirement.
- property arg
Retrieve the first extra requirement if available.
- Returns:
The first element in the extras list if it exists, otherwise None.
- static get_base_for_parametrized(name)[source]
Extracts the base project name from a given parameterized package name.
- Parameters:
name (str) – The parameterized package name to parse.
- Returns:
The base project name of the package.
- Return type:
str
- has_version_specs()[source]
Check if the requirement has version specifications.
- Returns:
True if there are version specifications, False otherwise.
- Return type:
bool
- static is_parametrized(name)[source]
Check if a package requirement is parametrized.
A parametrized package requirement includes extras, which are additional features or dependencies that can be optionally included.
- Parameters:
name (str) – The name of the package requirement to check.
- Returns:
- True if the package requirement is parametrized (includes extras),
False otherwise.
- Return type:
bool
- property name
Retrieve the project name from the requirement specifications.
- Returns:
The name of the project.
- Return type:
str
- property ver_specs
Retrieve the specifications.
- Returns:
The specifications stored in the instance.
- Return type:
dict
- class ssg.requirement_specs.RequirementParser(target_v: str)[source]
Bases:
objectA simple parser for package requirements with version specifiers. Handles formats like: package[extra]>=1.0,<2.0
- property extras: List[str]
- property project_name: str
- property specs: List[Tuple[str, str]]
- ssg.requirement_specs.parse_version_into_evr(version)[source]
Parses a version string into its epoch, version, and release components.
- Parameters:
version (str) – The version string to parse. It should be in the format ‘epoch:version-release’, where ‘epoch’ and ‘release’ are optional.
- Returns:
- A dictionary with keys ‘epoch’, ‘version’, and ‘release’, containing the respective
parts of the version string. If ‘epoch’ or ‘release’ are not present in the input string, their values will be None.
- Return type:
dict
- Raises:
ValueError – If the version string does not match the expected format.