Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions portable-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,10 @@ folders:
cpython-additional-packages:
# - Pillow==10.0.0
# - flake8==6.0.0

# Uncomment if you need to patch the source code of a module before compiling it
#cpython-modules: zlib
#zlib-patches:
# - file: configure
# regex: "# start off configure.log"
# replacement: "echo starting zlib configure script with patches"
13 changes: 13 additions & 0 deletions src/portable_python/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,9 @@ def is_usable_module(self, name):
def cfg_version(self, default):
return PPG.config.get_value("%s-version" % self.m_name) or default

def cfg_patches(self):
return PPG.config.get_value("%s-patches" % self.m_name)

@property
def url(self):
"""Url of source tarball, if any"""
Expand Down Expand Up @@ -639,6 +642,7 @@ def compile(self):
folder = folder / self.m_build_cwd

with runez.CurrentFolder(folder):
self._apply_patches()
self._prepare()
func()
self._finalize()
Expand All @@ -652,6 +656,15 @@ def compile(self):
else:
os.environ[k] = v

def _apply_patches(self):
if patches := self.cfg_patches():
for patch in patches:
if runez.DRYRUN:
print(f"Would apply patch: {patch}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: looks like patch_file() was naturally never called before in dryrun mode, but this could go in the patch_file() function itself (so that other places don't have to do/repeat if dryrun)

else:
print(f"Applying patch: {patch}")
patch_file(patch["file"], patch["regex"], patch["replacement"])

def _get_env_vars(self):
"""Yield all found env vars, first found wins"""
result = {}
Expand Down
Loading