-
Notifications
You must be signed in to change notification settings - Fork 88
Bump bandersnatch to 8.0 and bump required python_version to >=3.12 #1342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
gerrod3
wants to merge
2
commits into
pulp:main
Choose a base branch
from
gerrod3:bander8
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Upgraded Bandersnatch to 8.0. Full-index syncs now list packages from either the JSON or HTML representation of the Simple API. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Updated minimum required python version to >=3.12. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,14 @@ | ||
| import asyncio | ||
| import json | ||
| import logging | ||
| from functools import partial | ||
| from urllib.parse import urljoin, urlparse | ||
| from urllib.parse import urlparse | ||
|
|
||
| from aiohttp import ClientError, ClientResponseError | ||
| from bandersnatch.configuration import BandersnatchConfig | ||
| from bandersnatch.master import Master | ||
| from bandersnatch.mirror import Mirror | ||
| from lxml.etree import LxmlError | ||
| from packaging.requirements import Requirement | ||
| from pypi_simple import IndexPage | ||
| from pypi_simple import ACCEPT_ANY, IndexPage, UnsupportedContentTypeError | ||
|
|
||
| from pulpcore.plugin.download import HttpDownloader | ||
| from pulpcore.plugin.exceptions import SyncError | ||
|
|
@@ -169,41 +168,34 @@ def __init__(self, serial, master, workers, deferred_download, python_stage, pro | |
|
|
||
| async def determine_packages_to_sync(self): | ||
| """ | ||
| Calling this means that includes wasn't specified, | ||
| so try to get all of the packages from Mirror (hopefully PyPi) | ||
| Called when includes wasn't specified. List all projects from the remote's simple index. | ||
| """ | ||
| number_xmlrpc_attempts = 3 | ||
| for attempt in range(number_xmlrpc_attempts): | ||
| logger.info("Attempt {} to get package list from {}".format(attempt, self.master.url)) | ||
| try: | ||
| if not self.synced_serial: | ||
| logger.info("Syncing all packages.") | ||
| # First get the current serial, then start to sync. | ||
| all_packages = await self.master.all_packages() | ||
| self.packages_to_sync.update(all_packages) | ||
| self.target_serial = max( | ||
| [self.synced_serial] + [int(v) for v in self.packages_to_sync.values()] | ||
| ) | ||
| else: | ||
| logger.info("Syncing based on changelog.") | ||
| changed_packages = await self.master.changed_packages(self.synced_serial) | ||
| self.packages_to_sync.update(changed_packages) | ||
| self.target_serial = max( | ||
| [self.synced_serial] + [int(v) for v in self.packages_to_sync.values()] | ||
| ) | ||
| break | ||
| except (ClientError, ClientResponseError, LxmlError): | ||
| # Retry if XMLRPC endpoint failed, server might not support it. | ||
| continue | ||
| logger.info("Syncing all packages from %s", self.master.url) | ||
| url = f"{self.remote.url.rstrip('/')}/simple/" | ||
| downloader = self.remote.get_downloader(url=url) | ||
| result = await downloader.run( | ||
| extra_data={"request_kwargs": {"headers": {"Accept": ACCEPT_ANY}}} | ||
| ) | ||
|
|
||
| content_type = result.headers.get("Content-Type", "text/html").partition(";")[0].lower() | ||
| with open(result.path, "rb") as f: | ||
| content = f.read() | ||
|
|
||
| if content_type == "application/vnd.pypi.simple.v1+json": | ||
| index = IndexPage.from_json_data(json.loads(content)) | ||
| elif content_type in {"application/vnd.pypi.simple.v1+html", "text/html"}: | ||
| index = IndexPage.from_html(content) | ||
| else: | ||
| raise UnsupportedContentTypeError(url, content_type) | ||
|
|
||
| self.packages_to_sync = {project: 0 for project in index.projects} | ||
| last_serial = index.last_serial | ||
| if last_serial is None: | ||
| last_serial = result.headers.get(PYPI_LAST_SERIAL) | ||
| if last_serial is None: | ||
| self.target_serial = self.synced_serial | ||
| else: | ||
| logger.info("Failed to get package list using XMLRPC, trying parse simple page.") | ||
| url = urljoin(self.remote.url, "simple/") | ||
| downloader = self.remote.get_downloader(url=url) | ||
| result = await downloader.run() | ||
| with open(result.path) as f: | ||
| index = IndexPage.from_html(f.read()) | ||
| self.packages_to_sync.update({p: 0 for p in index.projects}) | ||
| self.target_serial = result.headers.get(PYPI_LAST_SERIAL, 0) | ||
| self.target_serial = max(self.synced_serial, int(last_serial)) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I understand correctly, |
||
|
|
||
| self._filter_packages() | ||
| if self.target_serial: | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.