Skip to content

Commit a3a5b83

Browse files
committed
Merge branch 'develop' into 5.0.x
2 parents fb286aa + e4524c1 commit a3a5b83

File tree

7 files changed

+76
-26
lines changed

7 files changed

+76
-26
lines changed

.github/workflows/linting.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ jobs:
1414
strategy:
1515
matrix:
1616
python-version: [3.6, 3.7, 3.8, 3.9, '3.10', '3.11', '3.12']
17-
1817
steps:
1918
- uses: actions/checkout@v3
2019

easybuild/framework/easyblock.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2351,7 +2351,7 @@ def check_readiness_step(self):
23512351
self.log.info("No module %s found. Not skipping anything." % self.full_mod_name)
23522352

23532353
# remove existing module file under --force (but only if --skip is not used)
2354-
elif build_option('force') or build_option('rebuild'):
2354+
elif (build_option('force') or build_option('rebuild')) and not build_option('dump_env_script'):
23552355
self.remove_module_file()
23562356

23572357
def fetch_step(self, skip_checksums=False):
@@ -2609,7 +2609,7 @@ def patch_step(self, beginpath=None, patches=None):
26092609
copy_patch = 'copy' in patch and 'sourcepath' not in patch
26102610

26112611
self.log.debug("Source index: %s; patch level: %s; source path suffix: %s; copy patch: %s",
2612-
srcind, level, srcpathsuffix, copy)
2612+
srcind, level, srcpathsuffix, copy_patch)
26132613

26142614
if beginpath is None:
26152615
try:

easybuild/framework/extensioneasyblock.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,18 +126,23 @@ def _set_start_dir(self):
126126
elif ext_start_dir is None:
127127
# This may be on purpose, e.g. for Python WHL files which do not get extracted
128128
self.log.debug("Start dir is not set.")
129-
else:
129+
elif self.start_dir:
130130
# non-existing start dir means wrong input from user
131-
warn_msg = "Provided start dir (%s) for extension %s does not exist: %s" % (self.start_dir, self.name,
132-
ext_start_dir)
131+
raise EasyBuildError("Provided start dir (%s) for extension %s does not exist: %s",
132+
self.start_dir, self.name, ext_start_dir)
133+
else:
134+
warn_msg = 'Failed to determine start dir for extension %s: %s' % (self.name, ext_start_dir)
133135
self.log.warning(warn_msg)
134136
print_warning(warn_msg, silent=build_option('silent'))
135137

136138
def install_extension(self, unpack_src=False):
137139
"""Common operations for extensions: unpacking sources, patching, ..."""
138140

139141
# unpack file if desired
140-
if unpack_src:
142+
if self.options.get('nosource', False):
143+
# If no source wanted use the start_dir from the main EC
144+
self.ext_dir = self.master.start_dir
145+
elif unpack_src:
141146
targetdir = os.path.join(self.master.builddir, remove_unwanted_chars(self.name))
142147
self.ext_dir = extract_file(self.src, targetdir, extra_options=self.unpack_options,
143148
change_into_dir=False, cmd=self.src_extract_cmd)
@@ -146,10 +151,9 @@ def install_extension(self, unpack_src=False):
146151
# because start_dir value is usually a relative path (if it is set)
147152
change_dir(self.ext_dir)
148153

149-
self._set_start_dir()
154+
self._set_start_dir()
155+
if self.start_dir:
150156
change_dir(self.start_dir)
151-
else:
152-
self._set_start_dir()
153157

154158
# patch if needed
155159
EasyBlock.patch_step(self, beginpath=self.ext_dir)

easybuild/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -439,9 +439,9 @@ def process_eb_args(eb_args, eb_go, cfg_settings, modtool, testing, init_session
439439
dry_run_mode = options.dry_run or options.dry_run_short or options.missing_modules
440440

441441
keep_available_modules = any((
442-
forced, dry_run_mode, options.extended_dry_run, any_pr_option_set, options.copy_ec, options.inject_checksums,
443-
options.sanity_check_only, options.inject_checksums_to_json)
444-
)
442+
forced, dry_run_mode, any_pr_option_set, options.copy_ec, options.dump_env_script, options.extended_dry_run,
443+
options.inject_checksums, options.inject_checksums_to_json, options.sanity_check_only
444+
))
445445

446446
# skip modules that are already installed unless forced, or unless an option is used that warrants not skipping
447447
if not keep_available_modules:

easybuild/tools/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ def mk_full_default_path(name, prefix=DEFAULT_PREFIX):
277277
'debug',
278278
'debug_lmod',
279279
'dump_autopep8',
280+
'dump_env_script',
280281
'enforce_checksums',
281282
'experimental',
282283
'extended_dry_run',

test/framework/easyblock.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1746,7 +1746,7 @@ def test_fetch_patches(self):
17461746
self.assertEqual(eb.patches[1]['level'], 4)
17471747
self.assertEqual(eb.patches[2]['name'], toy_patch)
17481748
self.assertEqual(eb.patches[2]['sourcepath'], 'foobar')
1749-
self.assertEqual(eb.patches[3]['name'], 'toy-0.0.tar.gz'),
1749+
self.assertEqual(eb.patches[3]['name'], 'toy-0.0.tar.gz')
17501750
self.assertEqual(eb.patches[3]['copy'], 'some/path')
17511751
self.assertEqual(eb.patches[4]['name'], toy_patch)
17521752
self.assertEqual(eb.patches[4]['level'], 0)
@@ -2280,18 +2280,25 @@ def test_extension_set_start_dir(self):
22802280
cwd = os.getcwd()
22812281
self.assertExists(cwd)
22822282

2283-
def check_ext_start_dir(expected_start_dir, unpack_src=True):
2283+
def check_ext_start_dir(expected_start_dir, unpack_src=True, parent_startdir=None):
22842284
"""Check start dir."""
22852285
# make sure we're in an existing directory at the start
22862286
change_dir(cwd)
2287+
22872288
eb = EasyBlock(ec['ec'])
2289+
if not os.path.exists(eb.builddir):
2290+
eb.make_builddir() # Required to exist for samefile
2291+
eb.cfg['start_dir'] = parent_startdir
2292+
22882293
eb.extensions_step(fetch=True, install=False)
22892294
# extract sources of the extension
22902295
ext = eb.ext_instances[-1]
22912296
ext.install_extension(unpack_src=unpack_src)
22922297

22932298
if expected_start_dir is None:
22942299
self.assertIsNone(ext.start_dir)
2300+
# Without a start dir we don't change the CWD
2301+
self.assertEqual(os.getcwd(), cwd)
22952302
else:
22962303
self.assertTrue(os.path.isabs(ext.start_dir))
22972304
if ext.start_dir != os.sep:
@@ -2301,14 +2308,8 @@ def check_ext_start_dir(expected_start_dir, unpack_src=True):
23012308
else:
23022309
abs_expected_start_dir = os.path.join(eb.builddir, expected_start_dir)
23032310
self.assertEqual(ext.start_dir, abs_expected_start_dir)
2304-
if not os.path.exists(eb.builddir):
2305-
eb.make_builddir() # Required to exist for samefile
23062311
self.assertTrue(os.path.samefile(ext.start_dir, abs_expected_start_dir))
2307-
if unpack_src:
23082312
self.assertTrue(os.path.samefile(os.getcwd(), abs_expected_start_dir))
2309-
else:
2310-
# When not unpacking we don't change the CWD
2311-
self.assertEqual(os.getcwd(), cwd)
23122313
remove_dir(eb.builddir)
23132314

23142315
ec['ec']['exts_defaultclass'] = 'DummyExtension'
@@ -2337,11 +2338,8 @@ def check_ext_start_dir(expected_start_dir, unpack_src=True):
23372338
'start_dir': 'nonexistingdir'}),
23382339
]
23392340
with self.mocked_stdout_stderr():
2340-
err_pattern = "Failed to change from .*barbar/barbar-0.0 to nonexistingdir.*"
2341+
err_pattern = r"Provided start dir \(nonexistingdir\) for extension barbar does not exist:.*"
23412342
self.assertErrorRegex(EasyBuildError, err_pattern, check_ext_start_dir, 'whatever')
2342-
stderr = self.get_stderr()
2343-
warning_pattern = "WARNING: Provided start dir (nonexistingdir) for extension barbar does not exist"
2344-
self.assertIn(warning_pattern, stderr)
23452343

23462344
# No error when using relative path in non-extracted source for some reason
23472345
ec['ec']['exts_list'] = [
@@ -2371,6 +2369,15 @@ def check_ext_start_dir(expected_start_dir, unpack_src=True):
23712369
check_ext_start_dir(os.sep, unpack_src=False)
23722370
self.assertFalse(self.get_stderr())
23732371

2372+
# Go to ECs start dir if nosource is used
2373+
ec['ec']['exts_list'] = [
2374+
('barbar', '0.0', {
2375+
'nosource': True}),
2376+
]
2377+
with self.mocked_stdout_stderr():
2378+
check_ext_start_dir(self.test_prefix, parent_startdir=self.test_prefix)
2379+
self.assertFalse(self.get_stderr())
2380+
23742381
def test_prepare_step(self):
23752382
"""Test prepare step (setting up build environment)."""
23762383
test_easyconfigs = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'easyconfigs', 'test_ecs')

test/framework/options.py

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4630,7 +4630,7 @@ def test_github_new_update_pr(self):
46304630
res = [d for d in res if os.path.basename(d) != os.path.basename(git_working_dir)]
46314631
if len(res) == 1:
46324632
unstaged_file_full = os.path.join(res[0], unstaged_file)
4633-
self.assertNotExists(unstaged_file_full), "%s not found in %s" % (unstaged_file, res[0])
4633+
self.assertNotExists(unstaged_file_full)
46344634
else:
46354635
self.fail("Found copy of easybuild-easyconfigs working copy")
46364636

@@ -5360,6 +5360,45 @@ def test_dump_env_script(self):
53605360
])
53615361
self.assertEqual(res.output.strip(), expected_out)
53625362

5363+
def test_dump_env_script_existing_module(self):
5364+
toy_ec = 'toy-0.0.eb'
5365+
5366+
os.chdir(self.test_prefix)
5367+
self._run_mock_eb([toy_ec, '--force'], do_build=True)
5368+
env_script = os.path.join(self.test_prefix, os.path.splitext(toy_ec)[0] + '.env')
5369+
test_module = os.path.join(self.test_installpath, 'modules', 'all', 'toy', '0.0')
5370+
if get_module_syntax() == 'Lua':
5371+
test_module += '.lua'
5372+
self.assertExists(test_module)
5373+
self.assertNotExists(env_script)
5374+
5375+
args = [toy_ec, '--dump-env']
5376+
os.chdir(self.test_prefix)
5377+
self._run_mock_eb(args, do_build=True, raise_error=True)
5378+
self.assertExists(env_script)
5379+
self.assertExists(test_module)
5380+
module_content = read_file(test_module)
5381+
env_file_content = read_file(env_script)
5382+
5383+
error_msg = (r"Script\(s\) already exists, not overwriting them \(unless --force is used\): "
5384+
+ os.path.basename(env_script))
5385+
os.chdir(self.test_prefix)
5386+
self.assertErrorRegex(EasyBuildError, error_msg, self._run_mock_eb, args, do_build=True, raise_error=True)
5387+
self.assertExists(env_script)
5388+
self.assertExists(test_module)
5389+
# Unchanged module and env file
5390+
self.assertEqual(read_file(test_module), module_content)
5391+
self.assertEqual(read_file(env_script), env_file_content)
5392+
5393+
args.append('--force')
5394+
os.chdir(self.test_prefix)
5395+
self._run_mock_eb(args, do_build=True, raise_error=True)
5396+
self.assertExists(env_script)
5397+
self.assertExists(test_module)
5398+
# Unchanged module and env file
5399+
self.assertEqual(read_file(test_module), module_content)
5400+
self.assertEqual(read_file(env_script), env_file_content)
5401+
53635402
def test_stop(self):
53645403
"""Test use of --stop."""
53655404
args = ['toy-0.0.eb', '--force', '--stop=configure']

0 commit comments

Comments
 (0)