Skip to content

Disable vendor C libraries only on Windows #4612

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

Closed
wants to merge 1 commit 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
1 change: 1 addition & 0 deletions news/4098.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Limit the disabling of requests' pyopenssl to Windows only. Fixes "SNIMissingWarning / InsecurePlatformWarning not fixable with pip 9.0 / 9.0.1" (for non-Windows)
2 changes: 1 addition & 1 deletion pip/_vendor/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Modifications
* ``pkg_resources`` has been modified to import its dependencies from ``pip._vendor``
* ``CacheControl`` has been modified to import its dependencies from ``pip._vendor``
* ``packaging`` has been modified to import its dependencies from ``pip._vendor``
* ``requests`` has been modified *not* to optionally load any C dependencies
* ``requests`` has been modified to *not* load C dependencies: ``simplejson`` (all platforms) and ``pyopenssl`` (Windows)
* Modified distro to delay importing ``argparse`` to avoid errors on 2.6


Expand Down
19 changes: 12 additions & 7 deletions pip/_vendor/requests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,19 @@
__license__ = 'Apache 2.0'
__copyright__ = 'Copyright 2016 Kenneth Reitz'


from pip.compat import WINDOWS


# Attempt to enable urllib3's SNI support, if possible
# Note: Patched by pip to prevent using the PyOpenSSL module. On Windows this
# prevents upgrading cryptography.
# try:
# from .packages.urllib3.contrib import pyopenssl
# pyopenssl.inject_into_urllib3()
# except ImportError:
# pass
# Note: Patched by pip to prevent using the PyOpenSSL module when OS is Windows.
# Otherwise on Windows this would prevent upgrading cryptography.
if not WINDOWS:
try:
from .packages.urllib3.contrib import pyopenssl
pyopenssl.inject_into_urllib3()
except ImportError:
pass

import warnings

Expand Down
28 changes: 17 additions & 11 deletions tasks/vendoring/patches/requests.patch
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
diff --git a/pip/_vendor/requests/__init__.py b/pip/_vendor/requests/__init__.py
index 9c3b769..44f6836 100644
index 9c3b769..36a4ef40 100644
--- a/pip/_vendor/requests/__init__.py
+++ b/pip/_vendor/requests/__init__.py
@@ -48,11 +48,13 @@ __license__ = 'Apache 2.0'
@@ -47,12 +47,19 @@ __author__ = 'Kenneth Reitz'
__license__ = 'Apache 2.0'
__copyright__ = 'Copyright 2016 Kenneth Reitz'


+
+from pip.compat import WINDOWS
+
+
# Attempt to enable urllib3's SNI support, if possible
-try:
- from .packages.urllib3.contrib import pyopenssl
- pyopenssl.inject_into_urllib3()
-except ImportError:
- pass
+# Note: Patched by pip to prevent using the PyOpenSSL module. On Windows this
+# prevents upgrading cryptography.
+# try:
+# from .packages.urllib3.contrib import pyopenssl
+# pyopenssl.inject_into_urllib3()
+# except ImportError:
+# pass

+# Note: Patched by pip to prevent using the PyOpenSSL module when OS is Windows.
+# Otherwise on Windows this would prevent upgrading cryptography.
+if not WINDOWS:
+ try:
+ from .packages.urllib3.contrib import pyopenssl
+ pyopenssl.inject_into_urllib3()
+ except ImportError:
+ pass

import warnings

diff --git a/pip/_vendor/requests/compat.py b/pip/_vendor/requests/compat.py
Expand Down