|
43 | 43 | class PipLoader:
|
44 | 44 | def __init__(self, real_spec):
|
45 | 45 | self.real_spec = real_spec
|
| 46 | + import os |
| 47 | + self._patches_base_dirs = [os.path.join(__graalpython__.core_home, "patches")] |
| 48 | + if hasattr(__graalpython__, "tdebug"): |
| 49 | + self._patches_base_dirs += os.environ.get('PIPLOADER_PATCHES_BASE_DIRS', "").split(",") |
46 | 50 |
|
47 | 51 | def create_module(self, spec):
|
48 | 52 | return self.real_spec.loader.create_module(self.real_spec)
|
@@ -72,7 +76,6 @@ def unpack_file(filename, location, *args, **kwargs):
|
72 | 76 |
|
73 | 77 | package_name = name_ver_match.group(1)
|
74 | 78 | is_sdist = name_ver_match.group(5) in ("tar.gz", "zip")
|
75 |
| - patches_base_dir = os.path.join(__graalpython__.core_home, "patches") |
76 | 79 |
|
77 | 80 | # NOTE: Following 3 functions are duplicated in ginstall.py:
|
78 | 81 | # creates a search list of a versioned file:
|
@@ -119,16 +122,17 @@ def apply_first_existing(dir, suffix, wd=None):
|
119 | 122 |
|
120 | 123 | print("Looking for Graal Python patches for " + package_name)
|
121 | 124 |
|
122 |
| - # patches intended for binary distribution: |
123 |
| - # we may need to change wd if we are actually patching the source distribution |
124 |
| - bdist_dir = os.path.join(patches_base_dir, package_name, "whl") |
125 |
| - bdist_patch_wd = read_first_existing(package_name, name_ver_match, bdist_dir, ".dir") if is_sdist else None |
126 |
| - apply_first_existing(bdist_dir, ".patch", bdist_patch_wd) |
127 |
| - |
128 |
| - # patches intended for source distribution if applicable |
129 |
| - if is_sdist: |
130 |
| - sdist_dir = os.path.join(patches_base_dir, package_name, "sdist") |
131 |
| - apply_first_existing(sdist_dir, ".patch") |
| 125 | + for pbd in self._patches_base_dirs: |
| 126 | + # patches intended for binary distribution: |
| 127 | + # we may need to change wd if we are actually patching the source distribution |
| 128 | + bdist_dir = os.path.join(pbd, package_name, "whl") |
| 129 | + bdist_patch_wd = read_first_existing(package_name, name_ver_match, bdist_dir, ".dir") if is_sdist else None |
| 130 | + apply_first_existing(bdist_dir, ".patch", bdist_patch_wd) |
| 131 | + |
| 132 | + # patches intended for source distribution if applicable |
| 133 | + if is_sdist: |
| 134 | + sdist_dir = os.path.join(pbd, package_name, "sdist") |
| 135 | + apply_first_existing(sdist_dir, ".patch") |
132 | 136 |
|
133 | 137 | return result
|
134 | 138 |
|
|
0 commit comments