File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -19,3 +19,10 @@ folders:
1919cpython-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"
Original file line number Diff line number Diff 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 = {}
You can’t perform that action at this time.
0 commit comments