|
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 | + os.environ.get('PIPLOADER_PATCHES_BASE_DIRS', "").split(",") |
46 | 49 |
|
47 | 50 | def create_module(self, spec): |
48 | 51 | return self.real_spec.loader.create_module(self.real_spec) |
@@ -72,7 +75,6 @@ def unpack_file(filename, location, *args, **kwargs): |
72 | 75 |
|
73 | 76 | package_name = name_ver_match.group(1) |
74 | 77 | is_sdist = name_ver_match.group(5) in ("tar.gz", "zip") |
75 | | - patches_base_dir = os.path.join(__graalpython__.core_home, "patches") |
76 | 78 |
|
77 | 79 | # NOTE: Following 3 functions are duplicated in ginstall.py: |
78 | 80 | # creates a search list of a versioned file: |
@@ -119,16 +121,18 @@ def apply_first_existing(dir, suffix, wd=None): |
119 | 121 |
|
120 | 122 | print("Looking for Graal Python patches for " + package_name) |
121 | 123 |
|
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") |
| 124 | + for pbd in self._patches_base_dirs: |
| 125 | + print("... checking " + pbd) |
| 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