From 3b8113d452f41fac6a5f7b10dca9633df2dce377 Mon Sep 17 00:00:00 2001 From: Pradyun Gedam Date: Sat, 11 Sep 2021 23:33:10 +0100 Subject: [PATCH] Bump to vendoring 1.0.x This now supports: - Clearer failure mode, for imports of the format `import x.y` - Regular expression support for dropping files (useful for when we vendor pygments) - Patching files prior to rewriting imports, allowing generation of patches on the original package sources. - Detection of py.typed files, which omits generation of unnecessary `.pyi` stubs. --- noxfile.py | 2 +- src/pip/_vendor/idna.pyi | 1 - src/pip/_vendor/packaging.pyi | 1 - src/pip/_vendor/resolvelib.pyi | 1 - src/pip/_vendor/tenacity.pyi | 1 - src/pip/_vendor/tomli.pyi | 1 - src/pip/_vendor/urllib3/contrib/pyopenssl.py | 4 +-- .../urllib3/contrib/securetransport.py | 4 +-- tools/vendoring/patches/requests.patch | 14 ++++----- tools/vendoring/patches/urllib3.patch | 29 +++++++++++++++++++ tox.ini | 2 +- 11 files changed, 42 insertions(+), 18 deletions(-) delete mode 100644 src/pip/_vendor/idna.pyi delete mode 100644 src/pip/_vendor/packaging.pyi delete mode 100644 src/pip/_vendor/resolvelib.pyi delete mode 100644 src/pip/_vendor/tenacity.pyi delete mode 100644 src/pip/_vendor/tomli.pyi create mode 100644 tools/vendoring/patches/urllib3.patch diff --git a/noxfile.py b/noxfile.py index 3cab71848d0..910e61eb51b 100644 --- a/noxfile.py +++ b/noxfile.py @@ -171,7 +171,7 @@ def lint(session: nox.Session) -> None: @nox.session def vendoring(session: nox.Session) -> None: - session.install("vendoring>=0.3.0") + session.install("vendoring~=1.0.0") if "--upgrade" not in session.posargs: session.run("vendoring", "sync", ".", "-v") diff --git a/src/pip/_vendor/idna.pyi b/src/pip/_vendor/idna.pyi deleted file mode 100644 index 7410d72fe7d..00000000000 --- a/src/pip/_vendor/idna.pyi +++ /dev/null @@ -1 +0,0 @@ -from idna import * \ No newline at end of file diff --git a/src/pip/_vendor/packaging.pyi b/src/pip/_vendor/packaging.pyi deleted file mode 100644 index 3458a3d6374..00000000000 --- a/src/pip/_vendor/packaging.pyi +++ /dev/null @@ -1 +0,0 @@ -from packaging import * \ No newline at end of file diff --git a/src/pip/_vendor/resolvelib.pyi b/src/pip/_vendor/resolvelib.pyi deleted file mode 100644 index b4ef4e108c4..00000000000 --- a/src/pip/_vendor/resolvelib.pyi +++ /dev/null @@ -1 +0,0 @@ -from resolvelib import * \ No newline at end of file diff --git a/src/pip/_vendor/tenacity.pyi b/src/pip/_vendor/tenacity.pyi deleted file mode 100644 index baf1de9dd9f..00000000000 --- a/src/pip/_vendor/tenacity.pyi +++ /dev/null @@ -1 +0,0 @@ -from tenacity import * \ No newline at end of file diff --git a/src/pip/_vendor/tomli.pyi b/src/pip/_vendor/tomli.pyi deleted file mode 100644 index b894db6919b..00000000000 --- a/src/pip/_vendor/tomli.pyi +++ /dev/null @@ -1 +0,0 @@ -from tomli import * \ No newline at end of file diff --git a/src/pip/_vendor/urllib3/contrib/pyopenssl.py b/src/pip/_vendor/urllib3/contrib/pyopenssl.py index c43146279d3..3130f51ac06 100644 --- a/src/pip/_vendor/urllib3/contrib/pyopenssl.py +++ b/src/pip/_vendor/urllib3/contrib/pyopenssl.py @@ -28,8 +28,8 @@ .. code-block:: python try: - import urllib3.contrib.pyopenssl - urllib3.contrib.pyopenssl.inject_into_urllib3() + import pip._vendor.urllib3.contrib.pyopenssl as pyopenssl + pyopenssl.inject_into_urllib3() except ImportError: pass diff --git a/src/pip/_vendor/urllib3/contrib/securetransport.py b/src/pip/_vendor/urllib3/contrib/securetransport.py index b9755545418..b4ca80b88be 100644 --- a/src/pip/_vendor/urllib3/contrib/securetransport.py +++ b/src/pip/_vendor/urllib3/contrib/securetransport.py @@ -19,8 +19,8 @@ To use this module, simply import and inject it:: - import urllib3.contrib.securetransport - urllib3.contrib.securetransport.inject_into_urllib3() + import pip._vendor.urllib3.contrib.securetransport as securetransport + securetransport.inject_into_urllib3() Happy TLSing! diff --git a/tools/vendoring/patches/requests.patch b/tools/vendoring/patches/requests.patch index d1bb4309b37..04e6339f484 100644 --- a/tools/vendoring/patches/requests.patch +++ b/tools/vendoring/patches/requests.patch @@ -6,7 +6,7 @@ index 0f8ae0d38..9582fa730 100644 import sys -try: -- from pip._vendor import chardet +- import chardet -except ImportError: - import charset_normalizer as chardet - import warnings @@ -40,7 +40,7 @@ diff --git a/src/pip/_vendor/requests/__init__.py b/src/pip/_vendor/requests/__i index 973497f5e..4f80e28fc 100644 --- a/src/pip/_vendor/requests/__init__.py +++ b/src/pip/_vendor/requests/__init__.py -@@ -44,10 +44,7 @@ from pip._vendor import urllib3 +@@ -44,10 +44,7 @@ import urllib3 import warnings from .exceptions import RequestsDependencyWarning @@ -51,7 +51,7 @@ index 973497f5e..4f80e28fc 100644 +charset_normalizer_version = None try: - from pip._vendor.chardet import __version__ as chardet_version + from chardet import __version__ as chardet_version @@ -107,6 +104,11 @@ except (AssertionError, ValueError): # if the standard library doesn't support SNI or the # 'ssl' library isn't available. @@ -74,10 +74,10 @@ index 409b7b028..9e2937167 100644 """ -try: -- from pip._vendor import chardet +- import chardet -except ImportError: - import charset_normalizer as chardet -+from pip._vendor import chardet ++import chardet import sys @@ -105,7 +105,7 @@ diff --git a/src/pip/_vendor/requests/help.py b/src/pip/_vendor/requests/help.py index 3a843404c..745f0d7b3 100644 --- a/src/pip/_vendor/requests/help.py +++ b/src/pip/_vendor/requests/help.py -@@ -11,10 +11,7 @@ from pip._vendor import urllib3 +@@ -11,10 +11,7 @@ import urllib3 from . import __version__ as requests_version @@ -116,4 +116,4 @@ index 3a843404c..745f0d7b3 100644 +charset_normalizer = None try: - from pip._vendor import chardet + import chardet diff --git a/tools/vendoring/patches/urllib3.patch b/tools/vendoring/patches/urllib3.patch new file mode 100644 index 00000000000..3ca7226fa6d --- /dev/null +++ b/tools/vendoring/patches/urllib3.patch @@ -0,0 +1,29 @@ +diff --git a/src/pip/_vendor/urllib3/contrib/securetransport.py b/src/pip/_vendor/urllib3/contrib/securetransport.py +index b97555454..189132baa 100644 +--- a/src/pip/_vendor/urllib3/contrib/securetransport.py ++++ b/src/pip/_vendor/urllib3/contrib/securetransport.py +@@ -19,8 +19,8 @@ + + To use this module, simply import and inject it:: + +- import urllib3.contrib.securetransport +- urllib3.contrib.securetransport.inject_into_urllib3() ++ import urllib3.contrib.securetransport as securetransport ++ securetransport.inject_into_urllib3() + + Happy TLSing! + +diff --git a/src/pip/_vendor/urllib3/contrib/pyopenssl.py b/src/pip/_vendor/urllib3/contrib/pyopenssl.py +index c43146279..4cded53f6 100644 +--- a/src/pip/_vendor/urllib3/contrib/pyopenssl.py ++++ b/src/pip/_vendor/urllib3/contrib/pyopenssl.py +@@ -28,7 +28,7 @@ + .. code-block:: python + + try: +- import urllib3.contrib.pyopenssl +- urllib3.contrib.pyopenssl.inject_into_urllib3() ++ import urllib3.contrib.pyopenssl as pyopenssl ++ pyopenssl.inject_into_urllib3() + except ImportError: + pass diff --git a/tox.ini b/tox.ini index a46ad04b7b3..23738ad1ae5 100644 --- a/tox.ini +++ b/tox.ini @@ -70,7 +70,7 @@ basepython = python3 skip_install = True commands_pre = deps = - vendoring~=0.3.3 + vendoring~=1.0.0 # Required, otherwise we interpret --no-binary :all: as # "do not build wheels", which fails for PEP 517 requirements pip>=19.3.1