2323 PYPI_REQUEST_TIMEOUT_SECONDS ,
2424 PYPI_SIMPLE_JSON ,
2525 PYPI_SIMPLE_URL ,
26- RELEASE_TAG_PATTERN ,
2726 RELEASE_TAG_PREFIX ,
2827 STDERR_TAIL_CHARACTERS ,
2928 UNIVERSAL_WHEEL_MACHINE ,
@@ -48,16 +47,13 @@ def release_versions(*, index: dict[str, object]) -> tuple[str, ...]:
4847 return _index_versions (index = index , include_yanked = False )
4948
5049
51- def choose_baseline (
52- * , candidate : str , index : dict [str , object ], tags : tuple [str , ...]
53- ) -> str | None :
54- """Return the highest installable or still-publishing release below the candidate."""
50+ def choose_baseline (* , candidate : str , index : dict [str , object ], same_version : bool ) -> str | None :
51+ """Return the highest release on PyPI below the candidate, or its own version when allowed."""
5552
56- listed : frozenset [str ] = frozenset (_index_versions (index = index , include_yanked = True ))
57- publishing : tuple [str , ...] = tuple (tag for tag in tags if tag not in listed )
58- return previous_version (
59- candidate = candidate , versions = (* release_versions (index = index ), * publishing )
60- )
53+ published : tuple [str , ...] = release_versions (index = index )
54+ if same_version and candidate in published :
55+ return candidate
56+ return previous_version (candidate = candidate , versions = published )
6157
6258
6359def previous_version (* , candidate : str , versions : tuple [str , ...]) -> str | None :
@@ -107,24 +103,6 @@ def fetch_simple_index() -> dict[str, object]:
107103 return cast (dict [str , object ], json .loads (response .read ()))
108104
109105
110- def tagged_versions (* , repo_dir : Path ) -> tuple [str , ...]:
111- """Return the X.Y.Z versions of the release tags in repo_dir, or none outside a clone."""
112-
113- completed : subprocess .CompletedProcess [str ] = subprocess .run (
114- ["git" , "-C" , str (repo_dir ), "tag" , "--list" , RELEASE_TAG_PATTERN ],
115- capture_output = True ,
116- text = True ,
117- check = False ,
118- )
119- if completed .returncode != 0 :
120- return ()
121- return tuple (
122- tag .removeprefix ("v" )
123- for tag in completed .stdout .split ()
124- if _RELEASE_VERSION .fullmatch (tag .removeprefix ("v" ))
125- )
126-
127-
128106def release_source (* , version : str , repo_dir : Path , destination : Path ) -> Path :
129107 """Extract the source tree of release tag v<version> from repo_dir into destination."""
130108
@@ -147,13 +125,11 @@ def release_source(*, version: str, repo_dir: Path, destination: Path) -> Path:
147125 return destination
148126
149127
150- def resolve_baseline (* , candidate : str , repo_dir : Path ) -> str :
151- """Return the highest published or not-yet-published tagged release below the candidate."""
128+ def resolve_baseline (* , candidate : str , same_version : bool ) -> str :
129+ """Return the baseline release that PyPI actually serves for the candidate."""
152130
153131 baseline : str | None = choose_baseline (
154- candidate = candidate ,
155- index = fetch_simple_index (),
156- tags = tagged_versions (repo_dir = repo_dir ),
132+ candidate = candidate , index = fetch_simple_index (), same_version = same_version
157133 )
158134 if baseline is None :
159135 raise ReleasePerformanceError (f"No published sqlbuild release precedes { candidate } " )
0 commit comments