38
38
# SOFTWARE.
39
39
40
40
"""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.
45
45
46
46
The PipInstallLoader takes care of the latter - when packages are installed
47
47
through the "install" or "wheel" commands, the argument version specs are
63
63
64
64
65
65
NAME_VER_PATTERN = "([^-]+)-(\\ d+)(.\\ d+)?(.\\ d+)?"
66
-
66
+ WARNED = False
67
67
68
68
class PipLoader :
69
69
def __init__ (self , real_spec ):
@@ -76,6 +76,15 @@ def __init__(self, real_spec):
76
76
def create_module (self , spec ):
77
77
return self .real_spec .loader .create_module (self .real_spec )
78
78
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
+
79
88
80
89
class PipInstallLoader (PipLoader ):
81
90
def exec_module (self , module ):
@@ -87,6 +96,7 @@ def exec_module(self, module):
87
96
try :
88
97
from pip ._vendor .packaging .requirements import Requirement
89
98
except :
99
+ self .print_version_warning ()
90
100
return exec_module_result
91
101
92
102
infos_printed = set ()
0 commit comments