def _execute(pkg): constraint = pkg.name if when is None else when when_spec = parse_anonymous_spec(constraint, pkg.name) cur_patches = pkg.patches.setdefault(when_spec, []) # if this spec is identical to some other, then append this # patch to the existing list. cur_patches.append(Patch.create(pkg, url_or_filename, level, **kwargs))
def patch(url_or_filename, **kwargs): """Packages can declare patches to apply to source. You can optionally provide a when spec to indicate that a particular patch should only be applied when the package's spec meets certain conditions (e.g. a particular version). """ pkg = get_calling_package_name() level = kwargs.get('level', 1) when_spec = parse_anonymous_spec(kwargs.get('when', pkg), pkg) patches = caller_locals().setdefault('patches', {}) if when_spec not in patches: patches[when_spec] = [Patch(pkg, url_or_filename, level)] else: # if this spec is identical to some other, then append this # patch to the existing list. patches[when_spec].append(Patch(pkg, url_or_filename, level))
def patch(pkg, url_or_filename, level=1, when=None): """Packages can declare patches to apply to source. You can optionally provide a when spec to indicate that a particular patch should only be applied when the package's spec meets certain conditions (e.g. a particular version). """ if when is None: when = pkg.name when_spec = parse_anonymous_spec(when, pkg.name) cur_patches = pkg.patches.setdefault(when_spec, []) # if this spec is identical to some other, then append this # patch to the existing list. cur_patches.append(Patch(pkg, url_or_filename, level))