parse version specifiers of the form ^x in min version checks

This commit is contained in:
Chester Curme 2024-11-12 16:16:01 -05:00
parent 09c3f787dd
commit 43b82f53cc

View File

@ -78,6 +78,11 @@ def get_minimum_version(package_name: str, spec_string: str) -> Optional[str]:
spec_string = re.sub(
rf"\^{x}\.(\d+)\.(\d+)", rf">={x}.\1.\2,<{x+1}", spec_string
)
# Rewrite occurrences of ^x to >=x.0.0,<x+1.0.0 (can be anywhere in constraint string)
for x in range(1, 10):
spec_string = re.sub(
rf"\^{x}(?!\.\d)", rf">={x}.0.0,<{x+1}.0.0", spec_string
)
spec_set = SpecifierSet(spec_string)
all_versions = get_pypi_versions(package_name)