Use shared client for publish tests and increase read timeout (#8538)

Attempts to address the read timeout case in
https://github.com/astral-sh/uv/issues/8418
This commit is contained in:
Zanie Blue 2024-10-24 14:24:57 -05:00 committed by GitHub
parent f4a3f97fe0
commit f533fe8d8b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 8 deletions

View File

@ -91,14 +91,14 @@ project_urls = {
}
def get_new_version(project_name: str) -> str:
def get_new_version(project_name: str, client: httpx.Client) -> str:
"""Return the next free path version on pypi"""
# 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
versions = set()
for url in project_urls[project_name]:
try:
data = httpx.get(url).text
data = client.get(url).text
except httpx.HTTPError as err:
raise RuntimeError(f"Failed to fetch {url}") from err
href_text = "<a[^>]+>([^<>]+)</a>"
@ -116,7 +116,7 @@ def get_new_version(project_name: str) -> str:
return ".".join(str(i) for i in release)
def create_project(project_name: str, uv: Path):
def create_project(project_name: str, uv: Path, client: httpx.Client):
if cwd.joinpath(project_name).exists():
rmtree(cwd.joinpath(project_name))
check_call([uv, "init", "--lib", project_name], cwd=cwd)
@ -124,18 +124,18 @@ def create_project(project_name: str, uv: Path):
# Set to an unclaimed version
toml = pyproject_toml.read_text()
new_version = get_new_version(project_name)
new_version = get_new_version(project_name, client)
toml = re.sub('version = ".*"', f'version = "{new_version}"', toml)
pyproject_toml.write_text(toml)
def publish_project(target: str, uv: Path):
def publish_project(target: str, uv: Path, client: httpx.Client):
project_name = all_targets[target]
print(f"\nPublish {project_name} for {target}")
# Create the project
create_project(project_name, uv)
create_project(project_name, uv, client)
# Build the project
check_call([uv, "build"], cwd=cwd.joinpath(project_name))
@ -264,8 +264,9 @@ def main():
else:
targets = args.targets
for project_name in targets:
publish_project(project_name, uv)
with httpx.Client(timeout=120) as client:
for project_name in targets:
publish_project(project_name, uv, client)
if __name__ == "__main__":