mafw.devtools.toolchain.pypi
PyPI version query utility for toolchain management.
This module provides a helper to query the PyPI JSON API for the latest
release version of a given package. It is used by all concrete
ToolChainTool implementations to
satisfy the detect_latest_version contract.
Functions
|
Query the PyPI JSON API for the latest release version of a package. |
- mafw.devtools.toolchain.pypi.fetch_latest_version(package_name: str, *, allow_prerelease: bool = False) Version[source]
Query the PyPI JSON API for the latest release version of a package.
This function fetches the package metadata from PyPI, extracts the
info.versionfield, and returns it as aVersion. Pre-release versions are filtered out unless explicitly allowed.When
allow_prereleaseis False and the latest version on PyPI is a pre-release, the function falls back to scanningreleaseskeys to find the most recent stable release.- Parameters:
package_name (str) – The PyPI package name to query (e.g.
"ruff").allow_prerelease (bool) – If True, pre-release versions are acceptable.
- Returns:
The latest available version from PyPI.
- Return type:
Version
- Raises:
DevtoolsError – If the HTTP request fails, the response cannot be parsed, or no suitable version is found.
- mafw.devtools.toolchain.pypi._PYPI_JSON_URL: Final[str] = 'https://pypi.org/pypi/{package}/json'
URL template for the PyPI JSON API endpoint.
- mafw.devtools.toolchain.pypi._REQUEST_TIMEOUT_S: Final[float] = 30.0
HTTP request timeout in seconds for PyPI queries.