Skip to content

Commit 28bcf94

Browse files
authored
Merge pull request #60 from solvingj/jwiltse/add_dep_patch_support
Add support to patch sources after download
2 parents 7f4105b + 7a0dea7 commit 28bcf94

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

portable-python.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,11 @@ cpython-additional-packages:
4646
# openssl-configure:
4747
# - -v
4848
# - --openssldir=/etc/ssl
49+
50+
51+
# Uncomment if you need to patch the source code of a module before compiling it
52+
#cpython-modules: zlib
53+
#zlib-patches:
54+
# - file: configure
55+
# regex: "# start off configure.log"
56+
# 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
@@ -502,6 +502,9 @@ def cfg_configure(self, deps_lib):
502502
configure_template = Template(configure)
503503
return configure_template.substitute(deps_lib=deps_lib)
504504

505+
def cfg_patches(self):
506+
return PPG.config.get_value("%s-patches" % self.m_name)
507+
505508
@property
506509
def url(self):
507510
"""Url of source tarball, if any"""
@@ -650,6 +653,7 @@ def compile(self):
650653
folder = folder / self.m_build_cwd
651654

652655
with runez.CurrentFolder(folder):
656+
self._apply_patches()
653657
self._prepare()
654658
func()
655659
self._finalize()
@@ -663,6 +667,15 @@ def compile(self):
663667
else:
664668
os.environ[k] = v
665669

670+
def _apply_patches(self):
671+
if patches := self.cfg_patches():
672+
for patch in patches:
673+
if runez.DRYRUN:
674+
print(f"Would apply patch: {patch}")
675+
else:
676+
print(f"Applying patch: {patch}")
677+
patch_file(patch["file"], patch["regex"], patch["replacement"])
678+
666679
def _get_env_vars(self):
667680
"""Yield all found env vars, first found wins"""
668681
result = {}

0 commit comments

Comments
 (0)