MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / _versions_from_parts

Function _versions_from_parts

tasks/scripts/release.py:89–134  ·  view source on GitHub ↗
(
    base_version: tuple[int, int, int],
    git_distance: int,
    git_sha: str,
    git_tag: str,
)

Source from the content-addressed store, hash-verified

87
88
89def _versions_from_parts(
90 base_version: tuple[int, int, int],
91 git_distance: int,
92 git_sha: str,
93 git_tag: str,
94) -> Versions:
95 if git_distance == 0:
96 python_version = _format_semver(base_version)
97 rpm_version = python_version
98 rpm_release = "1"
99 else:
100 next_version = _format_semver(_next_patch(base_version))
101 python_version = f"{next_version}.dev{git_distance}+g{git_sha}"
102 rpm_version = next_version
103 rpm_release = f"0.dev.{git_distance}.g{git_sha}"
104
105 # Convert PEP 440 to a SemVer-ish string for Cargo:
106 # 0.1.0.dev3+gabcdef -> 0.1.0-dev.3+gabcdef
107 cargo_version = re.sub(r"\.dev(\d+)", r"-dev.\1", python_version)
108
109 # Docker tags can't contain '+'.
110 docker_version = cargo_version.replace("+", "-")
111
112 # Snap versions cannot contain '+' and are limited to 32 characters.
113 snap_version = re.sub(r"\.d\d{8}$", "", docker_version)
114 if len(snap_version) > 32:
115 raise ValueError(f"snap version must be at most 32 characters: {snap_version}")
116
117 # Debian versions use '~' so prereleases sort before the eventual release.
118 deb_version = cargo_version
119 deb_version = deb_version[1:] if deb_version.startswith("v") else deb_version
120 deb_version = deb_version.replace("-dev.", "~dev.", 1)
121 deb_version = f"{deb_version}-1"
122
123 return Versions(
124 python=python_version,
125 cargo=cargo_version,
126 docker=docker_version,
127 deb=deb_version,
128 snap=snap_version,
129 rpm_version=rpm_version,
130 rpm_release=rpm_release,
131 git_tag=git_tag,
132 git_sha=git_sha,
133 git_distance=git_distance,
134 )
135
136
137def _compute_versions() -> Versions:

Callers 1

_compute_versionsFunction · 0.85

Calls 3

_format_semverFunction · 0.85
_next_patchFunction · 0.85
VersionsClass · 0.85

Tested by

no test coverage detected