-
Notifications
You must be signed in to change notification settings - Fork 1
Support older Python and find-links #11
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
base: pep-xxx-wheel-variants-dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,6 +51,7 @@ def __init__(self, path: str) -> None: | |
| self._path = path | ||
| self._page_candidates: List[str] = [] | ||
| self._project_name_to_urls: Dict[str, List[str]] = defaultdict(list) | ||
| self.variants_json = None | ||
| self._scanned_directory = False | ||
|
|
||
| def _scan_directory(self) -> None: | ||
|
|
@@ -71,6 +72,8 @@ def _scan_directory(self) -> None: | |
| try: | ||
| project_filename = parse_sdist_filename(entry.name)[0] | ||
| except InvalidSdistFilename: | ||
| if entry.name.endswith("-variants.json"): | ||
| self.variants_json = entry.path | ||
|
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. Doesn't this class have to account for multiple versions? If yes, then you'd probably need a dict from package names+versions to paths, similarly to how we do it in the regular codepath. |
||
| continue | ||
|
|
||
| self._project_name_to_urls[project_filename].append(url) | ||
|
|
@@ -130,6 +133,10 @@ def file_links(self) -> FoundLinks: | |
| for url in self._path_to_urls.project_name_to_urls[self._project_name]: | ||
| yield Link(url) | ||
|
|
||
| @property | ||
| def variants_json(self): | ||
| return self._path_to_urls.variants_json | ||
|
|
||
|
|
||
| class _LocalFileSource(LinkSource): | ||
| """``--find-links=<path-or-url>`` or ``--[extra-]index-url=<path-or-url>``. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,7 +49,7 @@ def __hash__(self) -> int: | |
| def get_variants_json_filename(wheel: Wheel) -> str: | ||
| # these are normalized, but with .replace("_", "-") | ||
| return ( | ||
| f"{wheel.name.replace("-", "_")}-{wheel.version.replace("-", "_")}-" | ||
| f"{wheel.name.replace('-', '_')}-{wheel.version.replace('-', '_')}-" | ||
|
Member
Author
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. This is for pre-PEP 701 compatibility. |
||
| "variants.json" | ||
| ) | ||
|
|
||
|
|
||
|
Member
Author
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. Presumably we would need this upstreamed to packaging itself as well (although we'll need the change in both places since pip will continue vendoring it anyway). 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. Yeah, kinda. I didn't change that API since we didn't need it at the time, and — well, it can't return the variant label, so it won't be correct for variant wheels anyway. That said, don't worry about upstreaming much — our pip fork is based on old version, and pip's changed too much in main to justify rebasing the demo. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a very clean way of doing things, but I figured better than nothing given that we're still prototyping. I'd be happy with a more structured solution at some point but I don't think it's urgent.