mafw.devtools.versions

Shared version parsing and formatting primitives for devtools.

PEP 440 distribution versions, Python interpreter minors, and version-bearing filenames have distinct syntax. This module centralizes their parsing while leaving caller-specific policy and error messages at their boundaries.

author:

Bulgheroni Antonio (antonio.bulgheroni@ec.europa.eu)

Module Attributes

PYTHON_MINOR_PATTERN

Exact syntax for a Python major.minor selector.

STABLE_TAG_PATTERN

Exact syntax for a stable project tag; callers must use fullmatch.

PYLOCK_REFERENCE_PATTERN

Exact syntax for a Python reference lock filename; use fullmatch.

Functions

build_pylock_reference_filename(python_version)

Build the reference lock filename for a Python minor token.

parse_pep440_version(value)

Parse value as a PEP 440 version using packaging.version.Version.

parse_pylock_reference_filename(file_name)

Parse an exact pylock reference filename, accepting a path-like input.

pylock_version_tag(python_version)

Convert a dotted Python minor token to the filename-safe underscore form.

Classes

PythonMinorVersion(major, minor)

A structural Python major.minor value for numeric ordering.

class mafw.devtools.versions.PythonMinorVersion(major: int, minor: int)[source]

Bases: object

A structural Python major.minor value for numeric ordering.

classmethod parse(value: str) → PythonMinorVersion[source]

Parse an exact major.minor token without applying project policy.

mafw.devtools.versions.build_pylock_reference_filename(python_version: str) → str[source]

Build the reference lock filename for a Python minor token.

mafw.devtools.versions.parse_pep440_version(value: str) → Version[source]

Parse value as a PEP 440 version using packaging.version.Version.

mafw.devtools.versions.parse_pylock_reference_filename(file_name: str) → tuple[str, str] | None[source]

Parse an exact pylock reference filename, accepting a path-like input.

mafw.devtools.versions.pylock_version_tag(python_version: str) → str[source]

Convert a dotted Python minor token to the filename-safe underscore form.

mafw.devtools.versions.PYLOCK_REFERENCE_PATTERN: Final[Pattern[str]] = re.compile('pylock\\.py(?P<python_version>3_\\d+)_ref\\.toml')

Exact syntax for a Python reference lock filename; use fullmatch.

mafw.devtools.versions.PYTHON_MINOR_PATTERN: Final[Pattern[str]] = re.compile('(?P<major>\\d+)\\.(?P<minor>\\d+)')

Exact syntax for a Python major.minor selector.

mafw.devtools.versions.STABLE_TAG_PATTERN: Final[Pattern[str]] = re.compile('v(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<micro>\\d+)')

Exact syntax for a stable project tag; callers must use fullmatch.