mirror of https://github.com/astral-sh/uv
Fix PyPI publish test script (#14116)
The script stumbled over a newline introduced in https://github.com/pypi/warehouse/pull/18266 (which is valid). Also fixed: Don't read versions for the same package from other indexes. We were using `project_name` here instead of `target`, while using the latter and only reading from a single index simplifies the code too.
This commit is contained in:
parent
2fc922144a
commit
499c8aa808
|
|
@ -163,15 +163,13 @@ all_targets: dict[str, TargetConfiguration] = local_targets | {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def get_latest_version(project_name: str, client: httpx.Client) -> Version:
|
def get_latest_version(target: str, client: httpx.Client) -> Version:
|
||||||
"""Return the latest version on all indexes of the package."""
|
"""Return the latest version on all indexes of the package."""
|
||||||
# To keep the number of packages small we reuse them across targets, so we have to
|
# To keep the number of packages small we reuse them across targets, so we have to
|
||||||
# pick a version that doesn't exist on any target yet
|
# pick a version that doesn't exist on any target yet
|
||||||
versions = set()
|
versions = set()
|
||||||
for target_config in all_targets.values():
|
target_config = all_targets[target]
|
||||||
if target_config.project_name != project_name:
|
url = target_config.index_url + target_config.project_name + "/"
|
||||||
continue
|
|
||||||
url = target_config.index_url + project_name + "/"
|
|
||||||
|
|
||||||
# Get with retries
|
# Get with retries
|
||||||
error = None
|
error = None
|
||||||
|
|
@ -182,7 +180,7 @@ def get_latest_version(project_name: str, client: httpx.Client) -> Version:
|
||||||
except httpx.HTTPError as err:
|
except httpx.HTTPError as err:
|
||||||
error = err
|
error = err
|
||||||
print(
|
print(
|
||||||
f"Error getting version for {project_name}, sleeping for 1s: {err}",
|
f"Error getting version for {target_config.project_name}, sleeping for 1s: {err}",
|
||||||
file=sys.stderr,
|
file=sys.stderr,
|
||||||
)
|
)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
@ -190,7 +188,7 @@ def get_latest_version(project_name: str, client: httpx.Client) -> Version:
|
||||||
# Sometimes there's a link that says "status page"
|
# Sometimes there's a link that says "status page"
|
||||||
error = err
|
error = err
|
||||||
print(
|
print(
|
||||||
f"Invalid index page for {project_name}, sleeping for 1s: {err}",
|
f"Invalid index page for {target_config.project_name}, sleeping for 1s: {err}",
|
||||||
file=sys.stderr,
|
file=sys.stderr,
|
||||||
)
|
)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
@ -223,7 +221,7 @@ def get_filenames(url: str, client: httpx.Client) -> list[str]:
|
||||||
response = client.get(url)
|
response = client.get(url)
|
||||||
data = response.text
|
data = response.text
|
||||||
# Works for the indexes in the list
|
# Works for the indexes in the list
|
||||||
href_text = r"<a(?: +[\w-]+=(?:'[^']+'|\"[^\"]+\"))* *>([^<>]+)</a>"
|
href_text = r"<a(?:\s*[\w-]+=(?:'[^']+'|\"[^\"]+\"))* *>([^<>]+)</a>"
|
||||||
return [m.group(1) for m in re.finditer(href_text, data)]
|
return [m.group(1) for m in re.finditer(href_text, data)]
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -363,7 +361,7 @@ def publish_project(target: str, uv: Path, client: httpx.Client):
|
||||||
print(f"\nPublish {project_name} for {target}", file=sys.stderr)
|
print(f"\nPublish {project_name} for {target}", file=sys.stderr)
|
||||||
|
|
||||||
# The distributions are build to the dist directory of the project.
|
# The distributions are build to the dist directory of the project.
|
||||||
previous_version = get_latest_version(project_name, client)
|
previous_version = get_latest_version(target, client)
|
||||||
version = get_new_version(previous_version)
|
version = get_new_version(previous_version)
|
||||||
project_dir = build_project_at_version(target, version, uv)
|
project_dir = build_project_at_version(target, version, uv)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue