Skip to content
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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PEP 658 metadata download to speed up builds #456

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/fromager/candidate.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,18 @@ def __init__(

self._metadata: Metadata | None = None
self._dependencies: list[Requirement] | None = None
self.metadata_source: str | None = None

def __repr__(self) -> str:
if not self.extras:
return f"<{self.name}=={self.version}>"
return f"<{self.name}[{','.join(self.extras)}]=={self.version}>"

def _pep_658_metadata(self):
# This function will download the metadata file from metadata_source url.
# Where do we save this? We will use seesions.get(self.metadata_source, stream=True)
pass

@property
def metadata(self) -> Metadata:
if self._metadata is None:
Expand Down
4 changes: 4 additions & 0 deletions src/fromager/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ def get_project_from_pypi(
for i in doc.findall(".//a"):
candidate_url = urljoin(simple_index_url, i.attrib["href"])
py_req = i.attrib.get("data-requires-python")
# As per PEP 658, the metadata file will be present separately in anchor tag "data-dist-info-metadata"
candidate_metadata_attr = i.attrib.get("data-dist-info-metadata")
candidate_metadata_url = urljoin(simple_index_url, candidate_metadata_attr)
path = urlparse(candidate_url).path
filename = path.rsplit("/", 1)[-1]
if DEBUG_RESOLVER:
Expand Down Expand Up @@ -178,6 +181,7 @@ def get_project_from_pypi(
is_sdist=is_sdist,
build_tag=build_tag,
)
c.metadata_source = candidate_metadata_url
if DEBUG_RESOLVER:
logger.debug(
"%s: candidate %s (%s) %s", project, filename, c, candidate_url
Expand Down
Loading