Skip to content

Commit e276c51

Browse files
authored
Merge pull request #4093 from akesandgren/fix-obtain_files-for-patch-with-alt_location
first look for patch in alt_location when it is specified
2 parents 6cab5e2 + 042d57a commit e276c51

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

easybuild/framework/easyblock.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -753,8 +753,15 @@ def obtain_file(self, filename, extension=False, urls=None, download_filename=No
753753
foundfile = None
754754
failedpaths = []
755755

756-
# always look first in the dir of the current eb file
757-
ebpath = [os.path.dirname(self.cfg.path)]
756+
# always look first in the dir of the current eb file unless alt_location is set
757+
if alt_location is None:
758+
ebpath = [os.path.dirname(self.cfg.path)]
759+
self.log.info("Considering directory in which easyconfig file is located when searching for %s: %s",
760+
filename, ebpath[0])
761+
else:
762+
ebpath = []
763+
self.log.info("Not considering directory in which easyconfig file is located when searching for %s "
764+
"because alt_location is set to %s", filename, alt_location)
758765

759766
# always consider robot + easyconfigs install paths as a fall back (e.g. for patch files, test cases, ...)
760767
common_filepaths = []

test/framework/easyblock.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1684,7 +1684,11 @@ def test_obtain_file(self):
16841684
mkdir(tmpdir_subdir, parents=True)
16851685
del os.environ['EASYBUILD_SOURCEPATH'] # defined by setUp
16861686

1687-
ec = process_easyconfig(os.path.join(testdir, 'easyconfigs', 'test_ecs', 't', 'toy', 'toy-0.0.eb'))[0]
1687+
toy_ec = os.path.join(testdir, 'easyconfigs', 'test_ecs', 't', 'toy', 'toy-0.0.eb')
1688+
test_ec = os.path.join(tmpdir, 'ecs', 'test.eb')
1689+
copy_file(toy_ec, test_ec)
1690+
1691+
ec = process_easyconfig(test_ec)[0]
16881692
eb = EasyBlock(ec['ec'])
16891693

16901694
# 'downloading' a file to (first) sourcepath works
@@ -1697,6 +1701,15 @@ def test_obtain_file(self):
16971701
res = eb.obtain_file(toy_tarball, urls=['file://%s' % tmpdir_subdir], alt_location='alt_toy')
16981702
self.assertEqual(res, os.path.join(tmpdir, 'a', 'alt_toy', toy_tarball))
16991703

1704+
# make sure that directory in which easyconfig file is located is *ignored* when alt_location is used
1705+
dummy_toy_tar_gz = os.path.join(os.path.dirname(test_ec), 'toy-0.0.tar.gz')
1706+
write_file(dummy_toy_tar_gz, '')
1707+
res = eb.obtain_file(toy_tarball, urls=['file://%s' % tmpdir_subdir])
1708+
self.assertEqual(res, dummy_toy_tar_gz)
1709+
res = eb.obtain_file(toy_tarball, urls=['file://%s' % tmpdir_subdir], alt_location='alt_toy')
1710+
self.assertEqual(res, os.path.join(tmpdir, 'a', 'alt_toy', toy_tarball))
1711+
remove_file(dummy_toy_tar_gz)
1712+
17001713
# finding a file in sourcepath works
17011714
init_config(args=["--sourcepath=%s:/no/such/dir:%s" % (sandbox_sources, tmpdir)])
17021715
res = eb.obtain_file(toy_tarball)

0 commit comments

Comments
 (0)