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

Extract URLFetcher for reuse with lock files. #1406

Merged
merged 1 commit into from
Aug 19, 2021

Conversation

jsirois
Copy link
Member

@jsirois jsirois commented Aug 19, 2021

Lock file generation will need to download and hash dists when their
hashes are not presented in PEP 503 link fragments and we'll also need
to download dists directly if we optimize the resolving from a lock file
case when the lock file contains urls ala PEP-665.

Work towards #1401.

Lock file generation will need to download and hash dists when their
hashes are not presented in PEP 503 link fragments and we'll also need
to download dists directly if we optimize the resolving from a lock file
case when the lock file contains urls ala PEP-665.

Work towards pex-tool#1401.
proxies = {protocol: network_configuration.proxy for protocol in ("http", "https")}

handlers = [ProxyHandler(proxies), HTTPSHandler(context=ssl_context)]
if handle_file_urls:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only changes to this class besides being moved from requirements.py to here are:

  1. Drop "ftp" from the proxy protocols above since we don't install the FtpHandler / never intended to support plaintext FTP.
  2. Add optional FileHandler support which will be needed / useful for handling --find-links "downloads" from local find-links repos in a way that keeps manual dist hashing code uniform / simpler.

@@ -108,13 +108,15 @@ def exec_function(ast, globals_map):

from urllib.error import HTTPError as HTTPError
from urllib.request import build_opener as build_opener
from urllib.request import FileHandler as FileHandler
Copy link
Member Author

@jsirois jsirois Aug 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

N.B.: On general Pex requirements for the uninitiated:

  1. It still supports Python 2.7
  2. It ships as both a distribution on PyPI and a Pex PEX via github releases.

2 makes it extremely unattractive to vendor requests since its (indirectly) platform-specific and the shipped Pex PEX - which is currently pure python - would need to grow multiplatform support that included {linux wheels, and two flavors of macOS wheels} X {2.7, 3.5...3.9}.

Copy link
Contributor

@Eric-Arellano Eric-Arellano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for splitting this out into prework :)

@jsirois jsirois merged commit c92de90 into pex-tool:main Aug 19, 2021
@jsirois jsirois deleted the issues/1401/extract_fetcher branch August 19, 2021 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants