Skip to content

Commit 7bd1bf6

Browse files
author
jwiltse
committed
Add support to patch dep sources after download
1 parent 89a6201 commit 7bd1bf6

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

portable-python.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,10 @@ folders:
1919
cpython-additional-packages:
2020
# - Pillow==10.0.0
2121
# - flake8==6.0.0
22+
23+
# Uncomment if you need to patch the source code of a module before compiling it
24+
#cpython-modules: zlib
25+
#zlib-patches:
26+
# - file: configure
27+
# regex: "# start off configure.log"
28+
# replacement: "echo starting zlib configure script with patches"

src/portable_python/__init__.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,9 @@ def is_usable_module(self, name):
491491
def cfg_version(self, default):
492492
return PPG.config.get_value("%s-version" % self.m_name) or default
493493

494+
def cfg_patches(self):
495+
return PPG.config.get_value("%s-patches" % self.m_name)
496+
494497
@property
495498
def url(self):
496499
"""Url of source tarball, if any"""
@@ -639,6 +642,7 @@ def compile(self):
639642
folder = folder / self.m_build_cwd
640643

641644
with runez.CurrentFolder(folder):
645+
self._apply_patches()
642646
self._prepare()
643647
func()
644648
self._finalize()
@@ -652,6 +656,15 @@ def compile(self):
652656
else:
653657
os.environ[k] = v
654658

659+
def _apply_patches(self):
660+
if patches := self.cfg_patches():
661+
for patch in patches:
662+
if runez.DRYRUN:
663+
print(f"Would apply patch: {patch}")
664+
else:
665+
print(f"Applying patch: {patch}")
666+
patch_file(patch["file"], patch["regex"], patch["replacement"])
667+
655668
def _get_env_vars(self):
656669
"""Yield all found env vars, first found wins"""
657670
result = {}

0 commit comments

Comments
 (0)