Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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 collective/recipe/patch/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ patches
patches = patches/my_very_sprecial.patch
patches/another_loverly.patch

no-uninstall
If set, patched paths will not be reported to buildout. This way,
the recipe can be used to patch code not installed by buildout.
A log of paths is kept in .patch-cache.txt (the filename can be
changed via 'patch-cache' option).


Example usage
=============

Expand Down
14 changes: 14 additions & 0 deletions collective/recipe/patch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def __init__(self, buildout, name, options):
self.options['executable'] = self.buildout[self.options['python']]['executable']
self.options['eggs-directory'] = buildout['buildout']['eggs-directory']
self.options['develop-eggs-directory'] = buildout['buildout']['develop-eggs-directory']
self.options['patch-cache'] = options.get("patch-cache", ".patch_cache.txt")

def install(self):
"""Installer"""
Expand Down Expand Up @@ -124,6 +125,10 @@ def use_patch_binary(self, path, patch):
raise zc.buildout.UserError('could not apply %s' % patch)
finally:
os.chdir(cwd)

if self.options.get("no-uninstall"):
self.log_patch_entry(path)
return ""
return path

def use_patch_library(self, path, patch):
Expand All @@ -135,4 +140,13 @@ def use_patch_library(self, path, patch):
logger.info('in %s...' % path)
if not patchlib.apply_patch(patch):
raise zc.buildout.UserError('could not apply %s' % name)
elif self.options.get("no-uninstall"):
self.log_patch_entry(path)
return ""
return path

def log_patch_entry(self, path):
"""log the patched path to $patch-cache"""
cachefilename = self.options.get("patch-cache")
with open(cachefilename, "a") as cachefile:
cachefile.write(path + "\n")