Make SSL optional in compatibility/fetcher - #3281
DonnaIsDoughnut wants to merge 1 commit into
Conversation
Interpreters built without SSL support (e.g. embedded / AOSP Python builds) don't define `urllib.request.HTTPSHandler` / `urllib2.HTTPSHandler` at all. Previously, importing pex.compatibility or pex.fetcher on such an interpreter would fail immediately. Now the SSL-specific imports are wrapped in try/except and a HAS_SSL flag tracks availability. URLFetcher only registers an HTTPSHandler when SSL is available, and eagerly initializing the default SSL context is skipped entirely in that case. Attempting to actually establish an HTTPS connection without SSL support now raises a clear IOError instead of failing at import time.
b6a7ab1 to
3a1c5e5
Compare
|
@DonnaIsDoughnut Pex does not use fetcher at runtime (i.e.: PEX files do not use fetcher). The Pex runtime does use compatibility though. As such, it seems to me compatibility ought to just be broken up and fetcher can own its imports. Since the Pex buildtime always needs a fetcher with https support and the Pex runtime never needs a fetcher, this should be a cleaner split. This is relevant: #88. Towards that end, what chip architectures do you target for embedded? I want to make sure pex.rc supports those if possible. Current target coverage can be seen here: https://github.com/pex-tool/pex.rc/blob/main/rust-toolchain I'll take a look at splitting things up as I suggest later today. |
|
Ok @DonnaIsDoughnut, I lied. The URLFetcher can be used at PEX runtime in 1 case: :; PEX_TOOLS=1 ./my.pex venv --pip /install/pex/in/this/venvIf the Python interpreter used does not have the |
|
@DonnaIsDoughnut please try out https://github.com/pex-tool/pex/releases/tag/v2.103.1 and close this PR if that fix works for your case. |
|
@DonnaIsDoughnut I'm going to close this next Friday, September 25th if I haven't head back from you about your experience with https://github.com/pex-tool/pex/releases/tag/v2.103.1. |
Fixes #3282
Interpreters built without SSL support (e.g. embedded / AOSP Python builds) don't define
urllib.request.HTTPSHandler/urllib2.HTTPSHandlerat all. Previously, importingpex.compatibilityorpex.fetcheron such an interpreter would fail immediately.This wraps the SSL-specific imports in try/except and adds a
HAS_SSLflag.URLFetcheronly registers anHTTPSHandlerwhen SSL is available, and eagerly initializing the default SSL context is skipped in that case. Attempting to actually establish an HTTPS connection without SSL support now raises a clearIOErrorinstead of failing at import time.