Skip to content

Commit 0779426

Browse files
authored
Merge pull request #15 from boegel/handle_patches_in_extensions_better
revert changes to patch_step + add test for extension patches
2 parents 8545231 + 2c64f4a commit 0779426

File tree

3 files changed

+33
-8
lines changed

3 files changed

+33
-8
lines changed

easybuild/framework/easyblock.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1878,27 +1878,25 @@ def extract_step(self):
18781878
else:
18791879
raise EasyBuildError("Unpacking source %s failed", src['name'])
18801880

1881-
def patch_step(self, beginpath=None, extension=False):
1881+
def patch_step(self, beginpath=None):
18821882
"""
18831883
Apply the patches
18841884
"""
18851885
for patch in self.patches:
18861886
self.log.info("Applying patch %s" % patch['name'])
18871887
trace_msg("applying patch %s" % patch['name'])
18881888

1889-
if not extension:
1890-
# patch source at specified index (first source if not specified)
1891-
srcind = patch.get('source', 0)
1889+
# patch source at specified index (first source if not specified)
1890+
srcind = patch.get('source', 0)
18921891
# if patch level is specified, use that (otherwise let apply_patch derive patch level)
18931892
level = patch.get('level', None)
18941893
# determine suffix of source path to apply patch in (if any)
18951894
srcpathsuffix = patch.get('sourcepath', patch.get('copy', ''))
18961895
# determine whether 'patch' file should be copied rather than applied
18971896
copy_patch = 'copy' in patch and 'sourcepath' not in patch
18981897

1899-
if not extension:
1900-
self.log.debug("Source index: %s; patch level: %s; source path suffix: %s; copy patch: %s",
1901-
srcind, level, srcpathsuffix, copy)
1898+
self.log.debug("Source index: %s; patch level: %s; source path suffix: %s; copy patch: %s",
1899+
srcind, level, srcpathsuffix, copy)
19021900

19031901
if beginpath is None:
19041902
try:

easybuild/framework/extensioneasyblock.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def run(self, unpack_src=False):
110110
change_dir(self.start_dir)
111111

112112
# patch if needed
113-
EasyBlock.patch_step(self, beginpath=self.ext_dir, extension=True)
113+
EasyBlock.patch_step(self, beginpath=self.ext_dir)
114114

115115
def sanity_check_step(self, exts_filter=None, custom_paths=None, custom_commands=None):
116116
"""

test/framework/toy_build.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,6 +1132,33 @@ def test_toy_patches(self):
11321132
archived_patch_file = os.path.join(repositorypath, 'toy', 'toy-0.0_fix-silly-typo-in-printf-statement.patch')
11331133
self.assertTrue(os.path.isfile(archived_patch_file))
11341134

1135+
def test_toy_extension_patches(self):
1136+
"""Test install toy that includes extensions with patches."""
1137+
test_ecs = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'easyconfigs', 'test_ecs')
1138+
toy_ec = os.path.join(test_ecs, 't', 'toy', 'toy-0.0.eb')
1139+
toy_ec_txt = read_file(toy_ec)
1140+
1141+
# create file that we'll copy via 'patches'
1142+
write_file(os.path.join(self.test_prefix, 'test.txt'), 'test123')
1143+
1144+
test_ec = os.path.join(self.test_prefix, 'test.eb')
1145+
test_ec_txt = '\n'.join([
1146+
toy_ec_txt,
1147+
'exts_list = [',
1148+
' ("bar", "0.0", {',
1149+
' "buildopts": " && ls -l test.txt",',
1150+
' "patches": [',
1151+
' "bar-0.0_fix-silly-typo-in-printf-statement.patch",', # normal patch
1152+
' ("bar-0.0_fix-very-silly-typo-in-printf-statement.patch", 0),', # patch with patch level
1153+
' ("test.txt", "."),', # file to copy to build dir (not a real patch file)
1154+
' ],',
1155+
' }),',
1156+
']',
1157+
])
1158+
write_file(test_ec, test_ec_txt)
1159+
1160+
self.test_toy_build(ec_file=test_ec)
1161+
11351162
def test_toy_module_fulltxt(self):
11361163
"""Strict text comparison of generated module file."""
11371164
self.test_toy_tweaked()

0 commit comments

Comments
 (0)