Skip to content

Commit ad7c18e

Browse files
committed
print a warning when we cannot patch pip
1 parent 332e8e1 commit ad7c18e

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

graalpython/lib-graalpython/pip_hook.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@
3838
# SOFTWARE.
3939

4040
"""The purpose of this import hook is two-fold. We have patches for certain
41-
packages to make the work on GraalPy. These patches need to be applied when
42-
the relevant packages are unpacked. Additionally, we want certain packages to
43-
always prefer known versions if that agrees with the version spec the user of
44-
pip install or the package has specified in its requirements.
41+
packages to make them work on GraalPy. These patches need to be applied when the
42+
relevant packages are unpacked. Additionally, we want certain packages to always
43+
prefer known versions if that agrees with the version spec the user of pip
44+
install or the package has specified in its requirements.
4545
4646
The PipInstallLoader takes care of the latter - when packages are installed
4747
through the "install" or "wheel" commands, the argument version specs are
@@ -63,7 +63,7 @@
6363

6464

6565
NAME_VER_PATTERN = "([^-]+)-(\\d+)(.\\d+)?(.\\d+)?"
66-
66+
WARNED = False
6767

6868
class PipLoader:
6969
def __init__(self, real_spec):
@@ -76,6 +76,15 @@ def __init__(self, real_spec):
7676
def create_module(self, spec):
7777
return self.real_spec.loader.create_module(self.real_spec)
7878

79+
def print_version_warning(self):
80+
global WARNED
81+
if not WARNED:
82+
print("WARNING: You are using an untested version of pip. GraalPy",
83+
"provides patches and workarounds for a number of packages when used with",
84+
"compatible pip versions. We recommend to stick with the pip version that",
85+
"ships with this version of GraalPy.")
86+
WARNED = True
87+
7988

8089
class PipInstallLoader(PipLoader):
8190
def exec_module(self, module):
@@ -87,6 +96,7 @@ def exec_module(self, module):
8796
try:
8897
from pip._vendor.packaging.requirements import Requirement
8998
except:
99+
self.print_version_warning()
90100
return exec_module_result
91101

92102
infos_printed = set()

0 commit comments

Comments
 (0)