Skip to content

Commit 18cb48c

Browse files
committed
Update CI for python 3.12
1 parent 4af8279 commit 18cb48c

8 files changed

Lines changed: 30 additions & 38 deletions

File tree

‎.github/workflows/build.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
path: "pulp-openapi-generator"
3434
- uses: "actions/setup-python@v6"
3535
with:
36-
python-version: "3.11"
36+
python-version: "3.12"
3737
- name: "Install uv"
3838
uses: "astral-sh/setup-uv@v7"
3939
with:

‎.github/workflows/create-branch.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838

3939
- uses: "actions/setup-python@v6"
4040
with:
41-
python-version: "3.11"
41+
python-version: "3.12"
4242
- name: "Install uv"
4343
uses: "astral-sh/setup-uv@v7"
4444
with:

‎.github/workflows/lint.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929

3030
- uses: "actions/setup-python@v6"
3131
with:
32-
python-version: "3.11"
32+
python-version: "3.12"
3333
- name: "Install uv"
3434
uses: "astral-sh/setup-uv@v7"
3535
with:

‎.github/workflows/release.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333

3434
- uses: "actions/setup-python@v6"
3535
with:
36-
python-version: "3.11"
36+
python-version: "3.12"
3737
- name: "Install uv"
3838
uses: "astral-sh/setup-uv@v7"
3939
with:

‎.github/workflows/update_ci.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434

3535
- uses: "actions/setup-python@v6"
3636
with:
37-
python-version: "3.11"
37+
python-version: "3.12"
3838
- name: "Install uv"
3939
uses: "astral-sh/setup-uv@v7"
4040
with:

‎CHANGES/+bandersnatch-8.feature‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Upgraded Bandersnatch to 8.0. Full-index syncs now list packages via the PEP 691 Simple JSON API, falling back to HTML `/simple/` when JSON is unavailable.
1+
Upgraded Bandersnatch to 8.0. Full-index syncs now list packages from either the JSON or HTML representation of the Simple API.

‎pulp_python/app/tasks/sync.py‎

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import asyncio
2+
import json
23
import logging
34
from functools import partial
4-
from urllib.parse import urljoin, urlparse
5+
from urllib.parse import urlparse
56

6-
from aiohttp import ClientError
77
from bandersnatch.configuration import BandersnatchConfig
88
from bandersnatch.master import Master
99
from bandersnatch.mirror import Mirror
1010
from packaging.requirements import Requirement
11-
from pypi_simple import IndexPage
11+
from pypi_simple import ACCEPT_ANY, IndexPage, UnsupportedContentTypeError
1212

1313
from pulpcore.plugin.download import HttpDownloader
1414
from pulpcore.plugin.exceptions import SyncError
@@ -168,36 +168,28 @@ def __init__(self, serial, master, workers, deferred_download, python_stage, pro
168168

169169
async def determine_packages_to_sync(self):
170170
"""
171-
Called when includes wasn't specified. List all projects from the remote
172-
via the PEP 691 Simple JSON API, falling back to HTML /simple/.
171+
Called when includes wasn't specified. List all projects from the remote's simple index.
173172
"""
174173
logger.info("Syncing all packages from %s", self.master.url)
175-
try:
176-
simple_index = await self.master.fetch_simple_index()
177-
if not isinstance(simple_index, dict) or "projects" not in simple_index:
178-
raise ValueError("Simple JSON index is missing a projects list")
179-
for project in simple_index["projects"]:
180-
name = project.get("name")
181-
if name is None:
182-
continue
183-
# _last-serial is a PyPI extension; default to 0 when absent
184-
self.packages_to_sync[name] = project.get("_last-serial", 0)
185-
self.target_serial = max(
186-
[self.synced_serial or 0] + [int(v) for v in self.packages_to_sync.values()]
187-
)
188-
except (ClientError, ValueError, TypeError, AttributeError) as exc:
189-
logger.info(
190-
"Failed to list packages via Simple JSON API (%s); "
191-
"falling back to HTML simple index.",
192-
exc,
193-
)
194-
url = urljoin(self.remote.url, "simple/")
195-
downloader = self.remote.get_downloader(url=url)
196-
result = await downloader.run()
197-
with open(result.path) as f:
198-
index = IndexPage.from_html(f.read())
199-
self.packages_to_sync.update({p: 0 for p in index.projects})
200-
self.target_serial = result.headers.get(PYPI_LAST_SERIAL, 0)
174+
url = f"{self.remote.url.rstrip('/')}/simple/"
175+
downloader = self.remote.get_downloader(url=url)
176+
result = await downloader.run(
177+
extra_data={"request_kwargs": {"headers": {"Accept": ACCEPT_ANY}}}
178+
)
179+
180+
content_type = result.headers.get("Content-Type", "text/html").partition(";")[0].lower()
181+
with open(result.path, "rb") as f:
182+
content = f.read()
183+
184+
if content_type == "application/vnd.pypi.simple.v1+json":
185+
index = IndexPage.from_json_data(json.loads(content))
186+
elif content_type in {"application/vnd.pypi.simple.v1+html", "text/html"}:
187+
index = IndexPage.from_html(content)
188+
else:
189+
raise UnsupportedContentTypeError(url, content_type)
190+
191+
self.packages_to_sync = {project: 0 for project in index.projects}
192+
self.target_serial = index.last_serial or result.headers.get(PYPI_LAST_SERIAL, 0)
201193

202194
self._filter_packages()
203195
if self.target_serial:

‎pulp_python/tests/functional/api/test_download_content.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def test_full_fixtures_to_pulp_sync(
4848
):
4949
"""
5050
This test checks that Pulp can fully sync another Python Package repository that is not
51-
PyPI. This lists projects via the Simple JSON API, falling back to HTML /simple/.
51+
PyPI. This lists projects from the remote's Simple API index.
5252
"""
5353
# Repository we are syncing from is the fixtures (default url)
5454
remote = python_remote_factory(includes=[], prereleases=True)

0 commit comments

Comments
 (0)