Skip to content

Commit c7c3c4e

Browse files
committed
Add env vars to disable graalpy-specific pip behaviors
1 parent 048181a commit c7c3c4e

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

graalpython/lib-graalpython/patches/pip/pip-23.0.1.patch

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ index c799413..bf52f00 100644
9292
# file in .data maps to same location as file in wheel root).
9393
diff --git a/pip/_internal/utils/graalpy.py b/pip/_internal/utils/graalpy.py
9494
new file mode 100644
95-
index 0000000..348baae
95+
index 0000000..f9b8dcc
9696
--- /dev/null
9797
+++ b/pip/_internal/utils/graalpy.py
98-
@@ -0,0 +1,203 @@
98+
@@ -0,0 +1,214 @@
9999
+# ATTENTION: GraalPy uses existence of this module to verify that it is
100100
+# running a patched pip in pip_hook.py
101101
+import os
@@ -114,6 +114,9 @@ index 0000000..348baae
114114
+if hasattr(__graalpython__, "tdebug"):
115115
+ PATCHES_BASE_DIRS += os.environ.get('PIPLOADER_PATCHES_BASE_DIRS', "").split(",")
116116
+
117+
+DISABLE_PATCHING = os.environ.get('PIP_GRAALPY_DISABLE_PATCHING', '').lower() in ('true', '1')
118+
+DISABLE_VERSION_SELECTION = os.environ.get('PIP_GRAALPY_DISABLE_VERSION_SELECTION', '').lower() in ('true', '1')
119+
+
117120
+
118121
+def normalize_name(name):
119122
+ return re.sub('[-_.]+', '-', name).lower()
@@ -189,10 +192,8 @@ index 0000000..348baae
189192
+ Note that 'location' must be the parent directory of the package directory itself.
190193
+ For example: /path/to/site-package and not /path/to/site-packages/mypackage.
191194
+ """
192-
+ import autopatch_capi
193-
+ import subprocess
194-
+
195-
+ autopatch_capi.auto_patch_tree(location)
195+
+ if DISABLE_PATCHING:
196+
+ return
196197
+
197198
+ # we expect filename to be something like "pytest-5.4.2-py3-none-any.whl"
198199
+ archive_name = os.path.basename(filename)
@@ -212,6 +213,11 @@ index 0000000..348baae
212213
+ # We already processed it when building from source
213214
+ return
214215
+
216+
+ import autopatch_capi
217+
+ import subprocess
218+
+
219+
+ autopatch_capi.auto_patch_tree(location)
220+
+
215221
+ print(f"Looking for GraalPy patches for {name}")
216222
+ repository = get_patch_repository()
217223
+
@@ -247,6 +253,9 @@ index 0000000..348baae
247253
+
248254
+
249255
+def apply_graalpy_sort_order(sort_key_func):
256+
+ if DISABLE_VERSION_SELECTION:
257+
+ return sort_key_func
258+
+
250259
+ def wrapper(self, candidate):
251260
+ default_sort_key = sort_key_func(self, candidate)
252261
+ priority = get_patch_repository().get_priority_for_version(candidate.name, str(candidate.version))
@@ -284,6 +293,8 @@ index 0000000..348baae
284293
+
285294
+
286295
+def mark_wheel(path):
296+
+ if DISABLE_PATCHING:
297+
+ return
287298
+ with zipfile.ZipFile(path, 'a') as z:
288299
+ dist_info = None
289300
+ for name in z.namelist():

0 commit comments

Comments
 (0)