File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed
Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff 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"
Original file line number Diff line number Diff 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 = {}
You can’t perform that action at this time.
0 commit comments