Skip to content

Commit 623c761

Browse files
committed
pip_hook.py: get extra patches locations via env var
1 parent 602a1a5 commit 623c761

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

graalpython/lib-graalpython/pip_hook.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@
4343
class PipLoader:
4444
def __init__(self, real_spec):
4545
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(",")
4649

4750
def create_module(self, spec):
4851
return self.real_spec.loader.create_module(self.real_spec)
@@ -72,7 +75,6 @@ def unpack_file(filename, location, *args, **kwargs):
7275

7376
package_name = name_ver_match.group(1)
7477
is_sdist = name_ver_match.group(5) in ("tar.gz", "zip")
75-
patches_base_dir = os.path.join(__graalpython__.core_home, "patches")
7678

7779
# NOTE: Following 3 functions are duplicated in ginstall.py:
7880
# creates a search list of a versioned file:
@@ -119,16 +121,18 @@ def apply_first_existing(dir, suffix, wd=None):
119121

120122
print("Looking for Graal Python patches for " + package_name)
121123

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")
132136

133137
return result
134138

0 commit comments

Comments
 (0)