Patch new pip to make it support the old private API of main()
This is needed to be able to use pip 19.3+ in ensurepip of older Pythons without patching all the Pythons.
This commit is contained in:
parent
f6e9c0640b
commit
af087f8054
28
callable-main.patch
Normal file
28
callable-main.patch
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
diff --git a/src/pip/_internal/__init__.py b/src/pip/_internal/__init__.py
|
||||||
|
index 8c0e4c58..76e280e5 100755
|
||||||
|
--- a/src/pip/_internal/__init__.py
|
||||||
|
+++ b/src/pip/_internal/__init__.py
|
||||||
|
@@ -1,2 +1,3 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
import pip._internal.utils.inject_securetransport # noqa
|
||||||
|
+from pip._internal import main # noqa
|
||||||
|
diff --git a/src/pip/_internal/main.py b/src/pip/_internal/main.py
|
||||||
|
index 1e922402..e52e04d8 100644
|
||||||
|
--- a/src/pip/_internal/main.py
|
||||||
|
+++ b/src/pip/_internal/main.py
|
||||||
|
@@ -45,3 +45,15 @@ def main(args=None):
|
||||||
|
command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
|
||||||
|
|
||||||
|
return command.main(cmd_args)
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+# Dark magic to make the main module itself callable.
|
||||||
|
+# This is needed to be able to use this pip in ensurepip of older Pythons
|
||||||
|
+# without patching all the Pythons.
|
||||||
|
+
|
||||||
|
+class _CallableModule(sys.modules[__name__].__class__):
|
||||||
|
+ def __call__(self, *args, **kwargs):
|
||||||
|
+ return main(*args, **kwargs)
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+sys.modules[__name__].__class__ = _CallableModule
|
@ -97,6 +97,15 @@ Patch4: dummy-certifi.patch
|
|||||||
Patch5: network-tests.patch
|
Patch5: network-tests.patch
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
|
# Dark magic to make pip 19.3+ support the old private API of main()
|
||||||
|
# This is needed to be able to use pip 19.3+ in ensurepip of older Pythons
|
||||||
|
# without patching all the Pythons
|
||||||
|
# A proper fix is discussed in:
|
||||||
|
# https://discuss.python.org/t/can-we-finally-add-a-minimal-api-to-pip/2833/3
|
||||||
|
# https://github.com/pypa/pip/pull/7061
|
||||||
|
# https://github.com/python/cpython/pull/16782
|
||||||
|
Patch6: callable-main.patch
|
||||||
|
|
||||||
# Downstream only patch
|
# Downstream only patch
|
||||||
# Users might have local installations of pip from using
|
# Users might have local installations of pip from using
|
||||||
# `pip install --user --upgrade pip` on older/newer versions.
|
# `pip install --user --upgrade pip` on older/newer versions.
|
||||||
@ -254,6 +263,7 @@ popd
|
|||||||
%if %{with tests}
|
%if %{with tests}
|
||||||
%patch5 -p1
|
%patch5 -p1
|
||||||
%endif
|
%endif
|
||||||
|
%patch6 -p1
|
||||||
|
|
||||||
# this goes together with patch4
|
# this goes together with patch4
|
||||||
rm src/pip/_vendor/certifi/*.pem
|
rm src/pip/_vendor/certifi/*.pem
|
||||||
|
Loading…
Reference in New Issue
Block a user