Mercurial > repos > shellac > sam_consensus_v3
comparison env/lib/python3.9/site-packages/pip/_internal/utils/inject_securetransport.py @ 0:4f3585e2f14b draft default tip
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author | shellac |
---|---|
date | Mon, 22 Mar 2021 18:12:50 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4f3585e2f14b |
---|---|
1 """A helper module that injects SecureTransport, on import. | |
2 | |
3 The import should be done as early as possible, to ensure all requests and | |
4 sessions (or whatever) are created after injecting SecureTransport. | |
5 | |
6 Note that we only do the injection on macOS, when the linked OpenSSL is too | |
7 old to handle TLSv1.2. | |
8 """ | |
9 | |
10 import sys | |
11 | |
12 | |
13 def inject_securetransport(): | |
14 # type: () -> None | |
15 # Only relevant on macOS | |
16 if sys.platform != "darwin": | |
17 return | |
18 | |
19 try: | |
20 import ssl | |
21 except ImportError: | |
22 return | |
23 | |
24 # Checks for OpenSSL 1.0.1 | |
25 if ssl.OPENSSL_VERSION_NUMBER >= 0x1000100f: | |
26 return | |
27 | |
28 try: | |
29 from pip._vendor.urllib3.contrib import securetransport | |
30 except (ImportError, OSError): | |
31 return | |
32 | |
33 securetransport.inject_into_urllib3() | |
34 | |
35 | |
36 inject_securetransport() |