-
Notifications
You must be signed in to change notification settings - Fork 704
/
easyconfigs.py
1740 lines (1499 loc) · 86.7 KB
/
easyconfigs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
##
# Copyright 2013-2024 Ghent University
#
# This file is part of EasyBuild,
# originally created by the HPC team of Ghent University (http://ugent.be/hpc/en),
# with support of Ghent University (http://ugent.be/hpc),
# the Flemish Supercomputer Centre (VSC) (https://www.vscentrum.be),
# Flemish Research Foundation (FWO) (http://www.fwo.be/en)
# and the Department of Economy, Science and Innovation (EWI) (http://www.ewi-vlaanderen.be/en).
#
# https://github.com/easybuilders/easybuild
#
# EasyBuild is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation v2.
#
# EasyBuild is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with EasyBuild. If not, see <http://www.gnu.org/licenses/>.
##
"""
Unit tests for easyconfig files.
@author: Kenneth Hoste (Ghent University)
"""
import glob
import os
import re
import shutil
import stat
import sys
import tempfile
from collections import defaultdict
from unittest import TestCase, TestLoader, main, skip
import easybuild.main as eb_main
import easybuild.tools.options as eboptions
from easybuild.base import fancylogger
from easybuild.easyblocks.generic.configuremake import ConfigureMake
from easybuild.easyblocks.generic.pythonpackage import PythonPackage
from easybuild.framework.easyblock import EasyBlock
from easybuild.framework.easyconfig.constants import EASYCONFIG_CONSTANTS
from easybuild.framework.easyconfig.default import DEFAULT_CONFIG
from easybuild.framework.easyconfig.format.format import DEPENDENCY_PARAMETERS
from easybuild.framework.easyconfig.easyconfig import get_easyblock_class, letter_dir_for
from easybuild.framework.easyconfig.easyconfig import resolve_template
from easybuild.framework.easyconfig.parser import EasyConfigParser, fetch_parameters_from_easyconfig
from easybuild.framework.easyconfig.tools import check_sha256_checksums, dep_graph, get_paths_for, process_easyconfig
from easybuild.tools import config, LooseVersion
from easybuild.tools.build_log import EasyBuildError
from easybuild.tools.config import GENERAL_CLASS, build_option
from easybuild.tools.filetools import change_dir, is_generic_easyblock, read_file, remove_file
from easybuild.tools.filetools import verify_checksum, which, write_file
from easybuild.tools.module_naming_scheme.utilities import det_full_ec_version
from easybuild.tools.modules import modules_tool
from easybuild.tools.py2vs3 import string_type, urlopen
from easybuild.tools.robot import check_conflicts, resolve_dependencies
from easybuild.tools.run import run_cmd
from easybuild.tools.options import set_tmpdir
from easybuild.tools.utilities import nub
# indicates whether all the single tests are OK,
# and that bigger tests (building dep graph, testing for conflicts, ...) can be run as well
# other than optimizing for time, this also helps to get around problems like http://bugs.python.org/issue10949
single_tests_ok = True
def is_pr():
"""Return true if run in a pull request CI"""
# $TRAVIS_PULL_REQUEST should be a PR number, otherwise we're not running tests for a PR
travis_pr_test = re.match('^[0-9]+$', os.environ.get('TRAVIS_PULL_REQUEST', ''))
# when testing a PR in GitHub Actions, $GITHUB_EVENT_NAME will be set to 'pull_request'
github_pr_test = os.environ.get('GITHUB_EVENT_NAME') == 'pull_request'
return travis_pr_test or github_pr_test
def get_target_branch():
"""Return the target branch of a pull request"""
# target branch should be anything other than 'master';
# usually is 'develop', but could also be a release branch like '3.7.x'
target_branch = os.environ.get('GITHUB_BASE_REF', None)
if not target_branch:
target_branch = os.environ.get('TRAVIS_BRANCH', None)
if not target_branch:
raise RuntimeError("Did not find a target branch")
return target_branch
def skip_if_not_pr_to_non_main_branch():
if not is_pr():
return skip("Only run for pull requests")
if get_target_branch() == "main":
return skip("Not run for pull requests against main")
return lambda func: func
def get_files_from_diff(diff_filter, ext):
"""Return the files changed on HEAD relative to the current target branch"""
target_branch = get_target_branch()
# relocate to top-level directory of repository to run 'git diff' command
top_dir = os.path.dirname(os.path.dirname(get_paths_for('easyconfigs')[0]))
cwd = change_dir(top_dir)
# first determine the 'merge base' between target branch and PR branch
# cfr. https://git-scm.com/docs/git-merge-base
cmd = "git merge-base %s HEAD" % target_branch
out, ec = run_cmd(cmd, simple=False, log_ok=False)
if ec == 0:
merge_base = out.strip()
print("Merge base for %s and HEAD: %s" % (target_branch, merge_base))
else:
msg = "Failed to determine merge base (ec: %s, output: '%s'), "
msg += "falling back to specifying target branch %s"
print(msg % (ec, out, target_branch))
merge_base = target_branch
# determine list of changed files using 'git diff' and merge base determined above
cmd = "git diff --name-only --diff-filter=%s %s..HEAD --" % (diff_filter, merge_base)
out, _ = run_cmd(cmd, simple=False)
files = [os.path.join(top_dir, f) for f in out.strip().split('\n') if f.endswith(ext)]
change_dir(cwd)
return files
def get_eb_files_from_diff(diff_filter):
"""Return the easyconfig files changed on HEAD relative to the current target branch"""
return get_files_from_diff(diff_filter, '.eb')
class EasyConfigTest(TestCase):
"""Baseclass for easyconfig testcases."""
@classmethod
def setUpClass(cls):
"""Setup environment for all tests. Called once!"""
# make sure that the EasyBuild installation is still known even if we purge an EB module
if os.getenv('EB_SCRIPT_PATH') is None:
eb_path = which('eb')
if eb_path is not None:
os.environ['EB_SCRIPT_PATH'] = eb_path
# initialize configuration (required for e.g. default modules_tool setting)
eb_go = eboptions.parse_options(args=[]) # Ignore cmdline args as those are meant for the unittest framework
config.init(eb_go.options, eb_go.get_options_by_section('config'))
build_options = {
'check_osdeps': False,
'external_modules_metadata': {},
'force': True,
'local_var_naming_check': 'error',
'optarch': 'test',
'robot_path': get_paths_for("easyconfigs")[0],
'silent': True,
'suffix_modules_path': GENERAL_CLASS,
'valid_module_classes': config.module_classes(),
'valid_stops': [x[0] for x in EasyBlock.get_steps()],
}
config.init_build_options(build_options=build_options)
set_tmpdir()
# put dummy 'craype-test' module in place, which is required for parsing easyconfigs using Cray* toolchains
cls.TMPDIR = tempfile.mkdtemp()
os.environ['MODULEPATH'] = cls.TMPDIR
write_file(os.path.join(cls.TMPDIR, 'craype-test'), '#%Module\n')
log = fancylogger.getLogger("EasyConfigTest", fname=False)
# make sure a logger is present for main
eb_main._log = log
cls._ordered_specs = None
cls._parsed_easyconfigs = []
cls._parsed_all_easyconfigs = False
cls._changed_ecs = None # easyconfigs changed in a PR
cls._changed_patches = None # patches changed in a PR
@classmethod
def tearDownClass(cls):
"""Cleanup after running all tests"""
shutil.rmtree(cls.TMPDIR)
@classmethod
def parse_all_easyconfigs(cls):
"""Parse all easyconfigs."""
if cls._parsed_all_easyconfigs:
return
# all available easyconfig files
easyconfigs_path = get_paths_for("easyconfigs")[0]
specs = glob.glob('%s/*/*/*.eb' % easyconfigs_path)
parsed_specs = set(ec['spec'] for ec in cls._parsed_easyconfigs)
for spec in specs:
if spec not in parsed_specs:
cls._parsed_easyconfigs.extend(process_easyconfig(spec))
cls._parsed_all_easyconfigs = True
@classmethod
def resolve_all_dependencies(cls):
"""Resolve dependencies between easyconfigs"""
# Parse all easyconfigs if not done yet
cls.parse_all_easyconfigs()
# filter out external modules
for ec in cls._parsed_easyconfigs:
for dep in ec['dependencies'][:]:
if dep.get('external_module', False):
ec['dependencies'].remove(dep)
cls._ordered_specs = resolve_dependencies(
cls._parsed_easyconfigs, modules_tool(), retain_all_deps=True)
def _get_changed_easyconfigs(self):
"""Gather all added or modified easyconfigs"""
# get list of changed easyconfigs
changed_ecs_files = get_eb_files_from_diff(diff_filter='M')
added_ecs_files = get_eb_files_from_diff(diff_filter='A')
# ignore template easyconfig (TEMPLATE.eb) and archived easyconfigs
def filter_ecs(ecs):
archive_path = os.path.join('easybuild', 'easyconfigs', '__archive__')
return [ec for ec in ecs if os.path.basename(ec) != 'TEMPLATE.eb' and archive_path not in ec]
changed_ecs_files = filter_ecs(changed_ecs_files)
added_ecs_files = filter_ecs(added_ecs_files)
changed_ecs_filenames = [os.path.basename(f) for f in changed_ecs_files]
added_ecs_filenames = [os.path.basename(f) for f in added_ecs_files]
if changed_ecs_filenames:
print("\nList of changed easyconfig files in this PR:\n\t%s" % '\n\t'.join(changed_ecs_filenames))
if added_ecs_filenames:
print("\nList of added easyconfig files in this PR:\n\t%s" % '\n\t'.join(added_ecs_filenames))
EasyConfigTest._changed_ecs_filenames = changed_ecs_filenames
EasyConfigTest._added_ecs_filenames = added_ecs_filenames
# grab parsed easyconfigs for changed easyconfig files
changed_ecs = []
easyconfigs_path = get_paths_for("easyconfigs")[0]
for ec_file in changed_ecs_files + added_ecs_files:
# Search in already parsed ECs first
match = next((ec['ec'] for ec in EasyConfigTest._parsed_easyconfigs if ec['spec'] == ec_file), None)
if match:
changed_ecs.append(match)
elif ec_file.startswith(easyconfigs_path):
ec = process_easyconfig(ec_file)
# Cache non-archived files
if '__archive__' not in ec_file:
EasyConfigTest._parsed_easyconfigs.extend(ec)
changed_ecs.append(ec[0]['ec'])
else:
raise RuntimeError("Failed to find parsed easyconfig for %s" % os.path.basename(ec_file))
EasyConfigTest._changed_ecs = changed_ecs
def _get_changed_patches(self):
"""Gather all added or modified patches"""
# get list of changed/added patch files
changed_patches = get_files_from_diff(diff_filter='M', ext='.patch')
added_patches = get_files_from_diff(diff_filter='A', ext='.patch')
if changed_patches:
print("\nList of changed patch files in this PR:\n\t%s" % '\n\t'.join(changed_patches))
if added_patches:
print("\nList of added patch files in this PR:\n\t%s" % '\n\t'.join(added_patches))
EasyConfigTest._changed_patches = changed_patches + added_patches
@property
def parsed_easyconfigs(self):
# parse all easyconfigs if they haven't been already
EasyConfigTest.parse_all_easyconfigs()
return EasyConfigTest._parsed_easyconfigs
@property
def ordered_specs(self):
# Resolve dependencies if not done
if EasyConfigTest._ordered_specs is None:
EasyConfigTest.resolve_all_dependencies()
return EasyConfigTest._ordered_specs
@property
def changed_ecs_filenames(self):
if EasyConfigTest._changed_ecs is None:
self._get_changed_easyconfigs()
return EasyConfigTest._changed_ecs_filenames
@property
def added_ecs_filenames(self):
if EasyConfigTest._changed_ecs is None:
self._get_changed_easyconfigs()
return EasyConfigTest._added_ecs_filenames
@property
def changed_ecs(self):
if EasyConfigTest._changed_ecs is None:
self._get_changed_easyconfigs()
return EasyConfigTest._changed_ecs
@property
def changed_patches(self):
if EasyConfigTest._changed_patches is None:
self._get_changed_patches()
return EasyConfigTest._changed_patches
def test_dep_graph(self):
"""Unit test that builds a full dependency graph."""
# pygraph dependencies required for constructing dependency graph are not available prior to Python 2.6
if LooseVersion(sys.version) >= LooseVersion('2.6') and single_tests_ok:
# temporary file for dep graph
(hn, fn) = tempfile.mkstemp(suffix='.dot')
os.close(hn)
dep_graph(fn, self.ordered_specs)
remove_file(fn)
else:
print("(skipped dep graph test)")
def test_conflicts(self):
"""Check whether any conflicts occur in software dependency graphs."""
if not single_tests_ok:
print("(skipped conflicts test)")
return
self.assertFalse(check_conflicts(self.ordered_specs, modules_tool(), check_inter_ec_conflicts=False),
"No conflicts detected")
def test_deps(self):
"""Perform checks on dependencies in easyconfig files"""
fails = []
for ec in self.parsed_easyconfigs:
# make sure we don't add backdoored XZ versions (5.6.0, 5.6.1)
# see https://access.redhat.com/security/cve/CVE-2024-3094
if ec['ec']['name'] == 'XZ' and ec['ec']['version'] in ('5.6.0', '5.6.1'):
fail = ("XZ versions 5.6.0 and 5.6.1 contain malicious code, and should not be introduced into"
" EasyBuild. Please use another version instead. For more details, see"
" https://access.redhat.com/security/cve/CVE-2024-3094")
fails.append(fail)
# make sure that no odd versions (like 1.13) of HDF5 are used as a dependency,
# since those are released candidates - only even versions (like 1.12) are stable releases;
# see https://docs.hdfgroup.org/archive/support/HDF5/doc/TechNotes/Version.html
for dep in ec['ec'].dependencies():
if dep['name'] == 'HDF5':
ver = dep['version']
if int(ver.split('.')[1]) % 2 == 1:
fail = "Odd minor versions of HDF5 should not be used as a dependency: "
fail += "found HDF5 v%s as dependency in %s" % (ver, os.path.basename(ec['spec']))
fails.append(fail)
self.assertFalse(len(fails), '\n'.join(sorted(fails)))
def check_dep_vars(self, gen, dep, dep_vars):
"""Check whether available variants of a particular dependency are acceptable or not."""
# 'guilty' until proven 'innocent'
res = False
# filter out wrapped Java or dotNET-Core versions
# i.e. if the version of one is a prefix of the version of the other one (e.g. 1.8 & 1.8.0_181)
if dep in ['Java', 'dotNET-Core']:
dep_vars_to_check = sorted(dep_vars.keys())
retained_dep_vars = []
while dep_vars_to_check:
dep_var = dep_vars_to_check.pop()
dep_var_version = dep_var.split(';')[0]
# remove dep vars wrapped by current dep var
dep_vars_to_check = [x for x in dep_vars_to_check if not x.startswith(dep_var_version + '.')]
retained_dep_vars = [x for x in retained_dep_vars if not x.startswith(dep_var_version + '.')]
retained_dep_vars.append(dep_var)
for key in list(dep_vars.keys()):
if key not in retained_dep_vars:
del dep_vars[key]
version_regex = re.compile('^version: (?P<version>[^;]+);')
# multiple variants of HTSlib is OK as long as they are deps for a matching version of BCFtools;
# same goes for WRF and WPS; Gurobi and Rgurobi; ncbi-vdb and SRA-Toolkit
multiple_allowed_variants = [('HTSlib', 'BCFtools'),
('WRF', 'WPS'),
('Gurobi', 'Rgurobi'),
('ncbi-vdb', 'SRA-Toolkit')]
for dep_name, parent_name in multiple_allowed_variants:
if dep == dep_name and len(dep_vars) > 1:
for key in list(dep_vars):
ecs = dep_vars[key]
# filter out dep variants that are only used as dependency for parent with same version
dep_ver = version_regex.search(key).group('version')
if all(ec.startswith('%s-%s-' % (parent_name, dep_ver)) for ec in ecs) and len(dep_vars) > 1:
dep_vars.pop(key)
# multiple variants of Meson is OK as long as they are deps for meson-python, since meson-python should only be
# a build dependency elsewhere
if dep == 'Meson' and len(dep_vars) > 1:
for key in list(dep_vars):
ecs = dep_vars[key]
# filter out Meson variants that are only used as a dependency for meson-python
if all(ec.startswith('meson-python-') for ec in ecs):
dep_vars.pop(key)
# always retain at least one dep variant
if len(dep_vars) == 1:
break
# multiple versions of Boost is OK as long as they are deps for a matching Boost.Python
if dep == 'Boost' and len(dep_vars) > 1:
for key in list(dep_vars):
ecs = dep_vars[key]
# filter out Boost variants that are only used as dependency for Boost.Python with same version
boost_ver = version_regex.search(key).group('version')
if all(ec.startswith('Boost.Python-%s-' % boost_ver) for ec in ecs):
dep_vars.pop(key)
# Pairs of name, versionsuffix that should be removed from dep_vars if exactly one matching key is found.
# The name is checked against 'dep' and can be a list to allow multiple
# If the versionsuffix is a 2-element tuple, the second element should be set to True
# to interpret the first element as the start of the suffix (e.g. to include trailing version numbers)
# Otherwise the whole versionsuffix must match for the filter to apply.
filter_variants = [
# filter out binutils with empty versionsuffix which is used to build toolchain compiler
('binutils', ''),
# filter out Perl with -minimal versionsuffix which are only used in makeinfo-minimal
('Perl', '-minimal'),
# filter out FFTW and imkl with -serial versionsuffix which are used in non-MPI subtoolchains
# Same for HDF5 with -serial versionsuffix which is used in HDF5 for Python (h5py)
(['FFTW', 'imkl', 'HDF5'], '-serial'),
# filter out BLIS and libFLAME with -amd versionsuffix
# (AMD forks, used in gobff/*-amd toolchains)
(['BLIS', 'libFLAME'], '-amd'),
# filter out libcint with -pypzpx versionsuffix, used by MOLGW
('libcint', '-pypzpx'),
# filter out OpenBLAS with -int8 versionsuffix, used by GAMESS-US
('OpenBLAS', '-int8'),
# filter out ScaLAPACK with -BLIS-* versionsuffix, used in goblf toolchain
('ScaLAPACK', ('-BLIS-', True)),
# filter out ScaLAPACK with -bf versionsuffix, used in gobff toolchain
('ScaLAPACK', '-bf'),
# filter out ScaLAPACK with -bl versionsuffix, used in goblf toolchain
('ScaLAPACK', '-bl'),
# filter out ELSI variants with -PEXSI suffix
('ELSI', '-PEXSI'),
# For Z3 the EC including Python bindings has a matching versionsuffix
# filter out one per Python version
('Z3', ('-Python-2', True)),
('Z3', ('-Python-3', True)),
]
for dep_name, version_suffix in filter_variants:
# always retain at least one dep variant
if len(dep_vars) == 1:
break
if isinstance(dep_name, string_type):
if dep != dep_name:
continue
elif dep not in dep_name:
continue
if isinstance(version_suffix, string_type):
match_prefix = False
else:
version_suffix, match_prefix = version_suffix
search = 'versionsuffix: ' + version_suffix
if match_prefix:
matches = [v for v in dep_vars if search in v]
else:
matches = [v for v in dep_vars if v.endswith(search)]
if len(matches) == 1:
del dep_vars[matches[0]]
# for some dependencies, we allow exceptions for software that depends on a particular version,
# as long as that's indicated by the versionsuffix
versionsuffix_deps = ['ASE', 'Boost', 'CUDA', 'CUDAcore', 'Java', 'Lua',
'PLUMED', 'PyTorch', 'R', 'Rust', 'TensorFlow']
if dep in versionsuffix_deps and len(dep_vars) > 1:
# check for '-CUDA-*' versionsuffix for CUDAcore dependency
if dep == 'CUDAcore':
dep = 'CUDA'
for key in list(dep_vars):
dep_ver = version_regex.search(key).group('version')
# use version of Java wrapper rather than full Java version
if dep == 'Java':
dep_ver = '.'.join(dep_ver.split('.')[:2])
# filter out dep version if all easyconfig filenames using it include specific dep version
if all(re.search('-%s-%s' % (dep, dep_ver), v) for v in dep_vars[key]):
dep_vars.pop(key)
# always retain at least one dep variant
if len(dep_vars) == 1:
break
# filter R dep for a specific version of Python 2.x
if dep == 'R' and len(dep_vars) > 1:
for key in list(dep_vars):
if '; versionsuffix: -Python-2' in key:
dep_vars.pop(key)
# always retain at least one variant
if len(dep_vars) == 1:
break
# for some dependencies, we allow exceptions for software with the same version
# but with a -int64 versionsuffix in both the dependency and all its dependents
int64_deps = ['SCOTCH', 'METIS']
if dep in int64_deps and len(dep_vars) > 1:
unique_dep_vers = {version_regex.search(x).group('version') for x in list(dep_vars)}
if len(unique_dep_vers) == 1:
for key in list(dep_vars):
if all(re.search('-int64', v) for v in dep_vars[key]) and re.search(
'; versionsuffix: .*-int64', key
):
dep_vars.pop(key)
# always retain at least one dep variant
if len(dep_vars) == 1:
break
# filter out variants that are specific to a particular version of CUDA
cuda_dep_vars = [v for v in dep_vars.keys() if '-CUDA' in v]
if len(dep_vars) >= len(cuda_dep_vars) and len(dep_vars) > 1:
for key in list(dep_vars):
if re.search('; versionsuffix: .*-CUDA-[0-9.]+', key):
dep_vars.pop(key)
# always retain at least one dep variant
if len(dep_vars) == 1:
break
# some software packages require a specific (older/newer) version of a particular dependency
alt_dep_versions = {
# jax 0.2.24 is used as dep for AlphaFold 2.1.2 (other easyconfigs with foss/2021a use jax 0.3.9)
'jax': [(r'0\.2\.24', [r'AlphaFold-2\.1\.2-foss-2021a'])],
# arrow-R 6.0.0.2 is used for two R/R-bundle-Bioconductor sets (4.1.2/3.14 and 4.2.0/3.15)
'arrow-R': [('6.0.0.2', [r'R-bundle-Bioconductor-'])],
# EMAN2 2.3 requires Boost(.Python) 1.64.0
'Boost': [('1.64.0;', [r'Boost.Python-1\.64\.0-', r'EMAN2-2\.3-'])],
'Boost.Python': [('1.64.0;', [r'EMAN2-2\.3-'])],
# GATE 9.2 requires CHLEP 2.4.5.1 and Geant4 11.0.x
'CLHEP': [('2.4.5.1;', [r'GATE-9\.2-foss-2021b'])],
# Score-P 8.3+ requires Cube 4.8.2+ but we have 4.8.1 already
'CubeLib': [(r'4\.8\.2;', [r'Score-P-8\.[3-9]'])],
'CubeWriter': [(r'4\.8\.2;', [r'Score-P-8\.[3-9]'])],
# egl variant of glew is required by libwpe, wpebackend-fdo + WebKitGTK+ depend on libwpe
'glew': [
('2.2.0; versionsuffix: -egl', [r'libwpe-1\.13\.3-GCCcore-11\.2\.0',
r'libwpe-1\.14\.1-GCCcore-11\.3\.0',
r'wpebackend-fdo-1\.13\.1-GCCcore-11\.2\.0',
r'wpebackend-fdo-1\.14\.1-GCCcore-11\.3\.0',
r'WebKitGTK\+-2\.37\.1-GCC-11\.2\.0',
r'wxPython-4\.2\.0',
r'wxPython-4\.2\.1',
r'GRASS-8\.2\.0',
r'QGIS-3\.28\.1']),
],
'Geant4': [('11.0.1;', [r'GATE-9\.2-foss-2021b'])],
# VMTK 1.4.x requires ITK 4.13.x
'ITK': [(r'4\.13\.', [r'VMTK-1\.4\.'])],
# Kraken 1.x requires Jellyfish 1.x (Roary & metaWRAP depend on Kraken 1.x)
'Jellyfish': [(r'1\.', [r'Kraken-1\.', r'Roary-3\.12\.0', r'metaWRAP-1\.2'])],
# Libint 1.1.6 is required by older CP2K versions
'Libint': [(r'1\.1\.6', [r'CP2K-[3-6]'])],
# libxc 2.x or 3.x is required by ABINIT, AtomPAW, CP2K, GPAW, horton, PySCF, WIEN2k
# libxc 4.x is required by libGridXC
# (Qiskit depends on PySCF), Elk 7.x requires libxc >= 5
'libxc': [
(r'[23]\.', [r'ABINIT-', r'AtomPAW-', r'CP2K-', r'GPAW-', r'horton-',
r'PySCF-', r'Qiskit-', r'WIEN2k-']),
(r'4\.', [r'libGridXC-']),
(r'5\.', [r'Elk-']),
],
# some software depends on numba, which typically requires an older LLVM;
# this includes BirdNET, cell2location, cryoDRGN, librosa, PyOD, Python-Geometric, scVelo, scanpy
'LLVM': [
# numba 0.47.x requires LLVM 7.x or 8.x (see https://github.com/numba/llvmlite#compatibility)
(r'8\.', [r'numba-0\.47\.0-', r'librosa-0\.7\.2-', r'BirdNET-20201214-',
r'scVelo-0\.1\.24-', r'PyTorch-Geometric-1\.[346]\.[23]', r'SHAP-0\.42\.1']),
(r'10\.0\.1', [r'cell2location-0\.05-alpha-', r'cryoDRGN-0\.3\.2-', r'loompy-3\.0\.6-',
r'numba-0\.52\.0-', r'PyOD-0\.8\.7-', r'PyTorch-Geometric-1\.6\.3',
r'scanpy-1\.7\.2-', r'umap-learn-0\.4\.6-']),
],
'Lua': [
# SimpleITK 2.1.0 requires Lua 5.3.x, MedPy and nnU-Net depend on SimpleITK
(r'5\.3\.5', [r'nnU-Net-1\.7\.0-', r'MedPy-0\.4\.0-', r'SimpleITK-2\.1\.0-']),
],
# FDMNES requires sequential variant of MUMPS
'MUMPS': [(r'5\.6\.1; versionsuffix: -metis-seq', [r'FDMNES'])],
# SRA-toolkit 3.0.0 requires ncbi-vdb 3.0.0, Finder requires SRA-Toolkit 3.0.0
'ncbi-vdb': [(r'3\.0\.0', [r'SRA-Toolkit-3\.0\.0', r'finder-1\.1\.0'])],
# TensorFlow 2.5+ requires a more recent NCCL than version 2.4.8 used in 2019b generation;
# Horovod depends on TensorFlow, so same exception required there
'NCCL': [(r'2\.11\.4', [r'TensorFlow-2\.[5-9]\.', r'Horovod-0\.2[2-9]'])],
# rampart requires nodejs > 10, artic-ncov2019 requires rampart
'nodejs': [('12.16.1', ['rampart-1.2.0rc3-', 'artic-ncov2019-2020.04.13'])],
# some software depends on an older numba;
# this includes BirdNET, cell2location, cryoDRGN, librosa, PyOD, Python-Geometric, scVelo, scanpy
'numba': [
(r'0\.52\.0', [r'cell2location-0\.05-alpha-', r'cryoDRGN-0\.3\.2-', r'loompy-3\.0\.6-',
r'PyOD-0\.8\.7-', r'PyTorch-Geometric-1\.6\.3', r'scanpy-1\.7\.2-',
r'umap-learn-0\.4\.6-']),
],
'OpenFOAM': [
# CFDEMcoupling requires OpenFOAM 5.x
(r'5\.0-20180606', [r'CFDEMcoupling-3\.8\.0']),
],
'ParaView': [
# OpenFOAM 5.0 requires older ParaView, CFDEMcoupling depends on OpenFOAM 5.0
(r'5\.4\.1', [r'CFDEMcoupling-3\.8\.0', r'OpenFOAM-5\.0-20180606']),
],
'pydantic': [
# GTDB-Tk v2.3.2 requires pydantic 1.x (see https://github.com/Ecogenomics/GTDBTk/pull/530)
('1.10.13;', ['GTDB-Tk-2.3.2-', 'GTDB-Tk-2.4.0-']),
('2.7.4;', ['MultiQC-1.22.3-']),
],
# medaka 1.1.*, 1.2.*, 1.4.* requires Pysam 0.16.0.1,
# which is newer than what others use as dependency w.r.t. Pysam version in 2019b generation;
# decona 0.1.2 and NGSpeciesID 0.1.1.1 depend on medaka 1.1.3
# WhatsHap 1.4 + medaka 1.6.0 require Pysam >= 0.18.0 (NGSpeciesID depends on medaka)
'Pysam': [
('0.16.0.1;', ['medaka-1.2.[0]-', 'medaka-1.1.[13]-', 'medaka-1.4.3-', 'decona-0.1.2-',
'NGSpeciesID-0.1.1.1-']),
('0.18.0;', ['medaka-1.6.0-', 'NGSpeciesID-0.1.2.1-', 'WhatsHap-1.4-']),
],
# OPERA requires SAMtools 0.x
'SAMtools': [(r'0\.', [r'ChimPipe-0\.9\.5', r'Cufflinks-2\.2\.1', r'OPERA-2\.0\.6',
r'CGmapTools-0\.1\.2', r'BatMeth2-2\.1', r'OPERA-MS-0\.9\.0-20240703'])],
# NanoPlot, NanoComp use an older version of Seaborn
'Seaborn': [(r'0\.10\.1', [r'NanoComp-1\.13\.1-', r'NanoPlot-1\.33\.0-'])],
# Shasta requires spoa 3.x
'spoa': [(r'3\.4\.0', [r'Shasta-0\.8\.0-'])],
# UShER requires tbb-2020.3 as newer versions will not build
# orthagogue requires tbb-2020.3 as 2021 versions are not backward compatible with the previous releases
'tbb': [('2020.3', ['UShER-0.5.0-', 'orthAgogue-20141105-'])],
'TensorFlow': [
# medaka 0.11.4/0.12.0 requires recent TensorFlow <= 1.14 (and Python 3.6),
# artic-ncov2019 requires medaka
('1.13.1;', ['medaka-0.11.4-', 'medaka-0.12.0-', 'artic-ncov2019-2020.04.13']),
# medaka 1.1.* and 1.2.* requires TensorFlow 2.2.0
# (while other 2019b easyconfigs use TensorFlow 2.1.0 as dep);
# TensorFlow 2.2.0 is also used as a dep for Horovod 0.19.5;
# decona 0.1.2 and NGSpeciesID 0.1.1.1 depend on medaka 1.1.3
('2.2.0;', ['medaka-1.2.[0]-', 'medaka-1.1.[13]-', 'Horovod-0.19.5-', 'decona-0.1.2-',
'NGSpeciesID-0.1.1.1-']),
# medaka 1.4.3 (foss/2019b) depends on TensorFlow 2.2.2
('2.2.2;', ['medaka-1.4.3-']),
# medaka 1.4.3 (foss/2020b) depends on TensorFlow 2.2.3; longread_umi and artic depend on medaka
('2.2.3;', ['medaka-1.4.3-', 'artic-ncov2019-2021.06.24-', 'longread_umi-0.3.2-']),
# AlphaFold 2.1.2 (foss/2020b) depends on TensorFlow 2.5.0
('2.5.0;', ['AlphaFold-2.1.2-']),
# medaka 1.5.0 (foss/2021a) depends on TensorFlow >=2.5.2, <2.6.0
('2.5.3;', ['medaka-1.5.0-']),
# tensorflow-probability version to TF version
('2.8.4;', ['tensorflow-probability-0.16.0-']),
],
# smooth-topk uses a newer version of torchvision
'torchvision': [('0.11.3;', ['smooth-topk-1.0-20210817-'])],
# for the sake of backwards compatibility, keep UCX-CUDA v1.11.0 which depends on UCX v1.11.0
# (for 2021b, UCX was updated to v1.11.2)
'UCX': [('1.11.0;', ['UCX-CUDA-1.11.0-'])],
# Napari 0.4.19post1 requires VisPy >=0.14.1 <0.15
'VisPy': [('0.14.1;', ['napari-0.4.19.post1-'])],
# Visit-3.4.1 requires VTK 9.2.x
'VTK': [('9.2.6;', ['Visit-3.4.1-'])],
# WPS 3.9.1 requires WRF 3.9.1.1
'WRF': [(r'3\.9\.1\.1', [r'WPS-3\.9\.1'])],
# wxPython 4.2.0 depends on wxWidgets 3.2.0
'wxWidgets': [(r'3\.2\.0', [r'wxPython-4\.2\.0', r'GRASS-8\.2\.0', r'QGIS-3\.28\.1'])],
}
if dep in alt_dep_versions and len(dep_vars) > 1:
for key in list(dep_vars):
for version_pattern, parents in alt_dep_versions[dep]:
# filter out known alternative dependency versions
if re.search('^version: %s' % version_pattern, key):
# only filter if the easyconfig using this dep variants is known
if all(any(re.search(p, x) for p in parents) for x in dep_vars[key]):
dep_vars.pop(key)
# only single variant is always OK
if len(dep_vars) == 1:
res = True
elif len(dep_vars) == 2 and dep in ['Python', 'Tkinter']:
# for Python & Tkinter, it's OK to have on 2.x and one 3.x version
v2_dep_vars = [x for x in dep_vars.keys() if x.startswith('version: 2.')]
v3_dep_vars = [x for x in dep_vars.keys() if x.startswith('version: 3.')]
if len(v2_dep_vars) == 1 and len(v3_dep_vars) == 1:
res = True
# two variants is OK if one is for Python 2.x and the other is for Python 3.x (based on versionsuffix)
elif len(dep_vars) == 2:
py2_dep_vars = [x for x in dep_vars.keys() if '; versionsuffix: -Python-2.' in x]
py3_dep_vars = [x for x in dep_vars.keys() if '; versionsuffix: -Python-3.' in x]
if len(py2_dep_vars) == 1 and len(py3_dep_vars) == 1:
res = True
# for recent generations, there's no versionsuffix anymore for Python 3,
# but we still allow variants depending on Python 2.x + 3.x
is_recent_gen = False
full_toolchain_regex = re.compile(r'^20[1-9][0-9][ab]$')
gcc_toolchain_regex = re.compile(r'^GCC(core)?-[0-9]?[0-9]\.[0-9]$')
if full_toolchain_regex.match(gen):
is_recent_gen = LooseVersion(gen) >= LooseVersion('2020b')
elif gcc_toolchain_regex.match(gen):
genver = gen.split('-', 1)[1]
is_recent_gen = LooseVersion(genver) >= LooseVersion('10.2')
else:
raise EasyBuildError("Unkown type of toolchain generation: %s" % gen)
if is_recent_gen:
py2_dep_vars = [x for x in dep_vars.keys() if '; versionsuffix: -Python-2.' in x]
py3_dep_vars = [x for x in dep_vars.keys() if x.strip().endswith('; versionsuffix:')]
if len(py2_dep_vars) == 1 and len(py3_dep_vars) == 1:
res = True
return res
def test_check_dep_vars(self):
"""Test check_dep_vars utility method."""
# one single dep version: OK
self.assertTrue(self.check_dep_vars('2019b', 'testdep', {
'version: 1.2.3; versionsuffix:': ['foo-1.2.3.eb', 'bar-4.5.6.eb'],
}))
self.assertTrue(self.check_dep_vars('2019b', 'testdep', {
'version: 1.2.3; versionsuffix: -test': ['foo-1.2.3.eb', 'bar-4.5.6.eb'],
}))
# two or more dep versions (no special case: not OK)
self.assertFalse(self.check_dep_vars('2019b', 'testdep', {
'version: 1.2.3; versionsuffix:': ['foo-1.2.3.eb'],
'version: 4.5.6; versionsuffix:': ['bar-4.5.6.eb'],
}))
self.assertFalse(self.check_dep_vars('2019b', 'testdep', {
'version: 0.0; versionsuffix:': ['foobar-0.0.eb'],
'version: 1.2.3; versionsuffix:': ['foo-1.2.3.eb'],
'version: 4.5.6; versionsuffix:': ['bar-4.5.6.eb'],
}))
# Java is a special case, with wrapped Java versions
self.assertTrue(self.check_dep_vars('2019b', 'Java', {
'version: 1.8.0_221; versionsuffix:': ['foo-1.2.3.eb'],
'version: 1.8; versionsuffix:': ['foo-1.2.3.eb'],
}))
# two Java wrappers is not OK
self.assertFalse(self.check_dep_vars('2019b', 'Java', {
'version: 1.8.0_221; versionsuffix:': ['foo-1.2.3.eb'],
'version: 1.8; versionsuffix:': ['foo-1.2.3.eb'],
'version: 11.0.2; versionsuffix:': ['bar-4.5.6.eb'],
'version: 11; versionsuffix:': ['bar-4.5.6.eb'],
}))
# OK to have two or more wrappers if versionsuffix is used to indicate exception
self.assertTrue(self.check_dep_vars('2019b', 'Java', {
'version: 1.8.0_221; versionsuffix:': ['foo-1.2.3.eb'],
'version: 1.8; versionsuffix:': ['foo-1.2.3.eb'],
'version: 11.0.2; versionsuffix:': ['bar-4.5.6-Java-11.eb'],
'version: 11; versionsuffix:': ['bar-4.5.6-Java-11.eb'],
}))
# versionsuffix must be there for all easyconfigs to indicate exception
self.assertFalse(self.check_dep_vars('2019b', 'Java', {
'version: 1.8.0_221; versionsuffix:': ['foo-1.2.3.eb'],
'version: 1.8; versionsuffix:': ['foo-1.2.3.eb'],
'version: 11.0.2; versionsuffix:': ['bar-4.5.6-Java-11.eb', 'bar-4.5.6.eb'],
'version: 11; versionsuffix:': ['bar-4.5.6-Java-11.eb', 'bar-4.5.6.eb'],
}))
self.assertTrue(self.check_dep_vars('2019b', 'Java', {
'version: 1.8.0_221; versionsuffix:': ['foo-1.2.3.eb'],
'version: 1.8; versionsuffix:': ['foo-1.2.3.eb'],
'version: 11.0.2; versionsuffix:': ['bar-4.5.6-Java-11.eb'],
'version: 11; versionsuffix:': ['bar-4.5.6-Java-11.eb'],
'version: 12.1.6; versionsuffix:': ['foobar-0.0-Java-12.eb'],
'version: 12; versionsuffix:': ['foobar-0.0-Java-12.eb'],
}))
# strange situation: odd number of Java versions
# not OK: two Java wrappers (and no versionsuffix to indicate exception)
self.assertFalse(self.check_dep_vars('2019b', 'Java', {
'version: 1.8.0_221; versionsuffix:': ['foo-1.2.3.eb'],
'version: 1.8; versionsuffix:': ['foo-1.2.3.eb'],
'version: 11; versionsuffix:': ['bar-4.5.6.eb'],
}))
# OK because of -Java-11 versionsuffix
self.assertTrue(self.check_dep_vars('2019b', 'Java', {
'version: 1.8.0_221; versionsuffix:': ['foo-1.2.3.eb'],
'version: 1.8; versionsuffix:': ['foo-1.2.3.eb'],
'version: 11; versionsuffix:': ['bar-4.5.6-Java-11.eb'],
}))
# not OK: two Java wrappers (and no versionsuffix to indicate exception)
self.assertFalse(self.check_dep_vars('2019b', 'Java', {
'version: 1.8; versionsuffix:': ['foo-1.2.3.eb'],
'version: 11.0.2; versionsuffix:': ['bar-4.5.6.eb'],
'version: 11; versionsuffix:': ['bar-4.5.6.eb'],
}))
# OK because of -Java-11 versionsuffix
self.assertTrue(self.check_dep_vars('2019b', 'Java', {
'version: 1.8; versionsuffix:': ['foo-1.2.3.eb'],
'version: 11.0.2; versionsuffix:': ['bar-4.5.6-Java-11.eb'],
'version: 11; versionsuffix:': ['bar-4.5.6-Java-11.eb'],
}))
# two different versions of Boost is not OK
self.assertFalse(self.check_dep_vars('2019b', 'Boost', {
'version: 1.64.0; versionsuffix:': ['foo-1.2.3.eb'],
'version: 1.70.0; versionsuffix:': ['foo-2.3.4.eb'],
}))
# a different Boost version that is only used as dependency for a matching Boost.Python is fine
self.assertTrue(self.check_dep_vars('2019a', 'Boost', {
'version: 1.64.0; versionsuffix:': ['Boost.Python-1.64.0-gompi-2019a.eb'],
'version: 1.70.0; versionsuffix:': ['foo-2.3.4.eb'],
}))
self.assertTrue(self.check_dep_vars('2019a', 'Boost', {
'version: 1.64.0; versionsuffix:': ['Boost.Python-1.64.0-gompi-2019a.eb'],
'version: 1.66.0; versionsuffix:': ['Boost.Python-1.66.0-gompi-2019a.eb'],
'version: 1.70.0; versionsuffix:': ['foo-2.3.4.eb'],
}))
self.assertFalse(self.check_dep_vars('2019a', 'Boost', {
'version: 1.64.0; versionsuffix:': ['Boost.Python-1.64.0-gompi-2019a.eb'],
'version: 1.66.0; versionsuffix:': ['foo-1.2.3.eb'],
'version: 1.70.0; versionsuffix:': ['foo-2.3.4.eb'],
}))
self.assertTrue(self.check_dep_vars('2018a', 'Boost', {
'version: 1.63.0; versionsuffix: -Python-2.7.14': ['EMAN2-2.21a-foss-2018a-Python-2.7.14-Boost-1.63.0.eb'],
'version: 1.64.0; versionsuffix:': ['Boost.Python-1.64.0-gompi-2018a.eb'],
'version: 1.66.0; versionsuffix:': ['BLAST+-2.7.1-foss-2018a.eb'],
}))
self.assertTrue(self.check_dep_vars('2019a', 'Boost', {
'version: 1.64.0; versionsuffix:': [
'Boost.Python-1.64.0-gompi-2019a.eb',
'EMAN2-2.3-foss-2019a-Python-2.7.15.eb',
],
'version: 1.70.0; versionsuffix:': [
'BLAST+-2.9.0-gompi-2019a.eb',
'Boost.Python-1.70.0-gompi-2019a.eb',
],
}))
# two variants is OK, if they're for Python 2.x and 3.x
self.assertTrue(self.check_dep_vars('2020a', 'Python', {
'version: 2.7.18; versionsuffix:': ['SciPy-bundle-2020.03-foss-2020a-Python-2.7.18.eb'],
'version: 3.8.2; versionsuffix:': ['SciPy-bundle-2020.03-foss-2020a-Python-3.8.2.eb'],
}))
self.assertTrue(self.check_dep_vars('2020a', 'SciPy-bundle', {
'version: 2020.03; versionsuffix: -Python-2.7.18': ['matplotlib-3.2.1-foss-2020a-Python-2.7.18.eb'],
'version: 2020.03; versionsuffix: -Python-3.8.2': ['matplotlib-3.2.1-foss-2020a-Python-3.8.2.eb'],
}))
# for recent easyconfig generations, there's no versionsuffix anymore for Python 3
self.assertTrue(self.check_dep_vars('2020b', 'Python', {
'version: 2.7.18; versionsuffix:': ['SciPy-bundle-2020.11-foss-2020b-Python-2.7.18.eb'],
'version: 3.8.6; versionsuffix:': ['SciPy-bundle-2020.11-foss-2020b.eb'],
}))
self.assertTrue(self.check_dep_vars('GCCcore-10.2', 'PyYAML', {
'version: 5.3.1; versionsuffix:': ['IPython-7.18.1-GCCcore-10.2.0.eb'],
'version: 5.3.1; versionsuffix: -Python-2.7.18': ['IPython-7.18.1-GCCcore-10.2.0-Python-2.7.18.eb'],
}))
self.assertTrue(self.check_dep_vars('2020b', 'SciPy-bundle', {
'version: 2020.11; versionsuffix: -Python-2.7.18': ['matplotlib-3.3.3-foss-2020b-Python-2.7.18.eb'],
'version: 2020.11; versionsuffix:': ['matplotlib-3.3.3-foss-2020b.eb'],
}))
# not allowed for older generations (foss/intel 2020a or older, GCC(core) 10.1.0 or older)
self.assertFalse(self.check_dep_vars('2020a', 'SciPy-bundle', {
'version: 2020.03; versionsuffix: -Python-2.7.18': ['matplotlib-3.2.1-foss-2020a-Python-2.7.18.eb'],
'version: 2020.03; versionsuffix:': ['matplotlib-3.2.1-foss-2020a.eb'],
}))
# multiple dependency variants of specific software is OK, but only if indicated via versionsuffix
self.assertTrue(self.check_dep_vars('2019b', 'TensorFlow', {
'version: 1.15.2; versionsuffix: -TensorFlow-1.15.2':
['Horovod-0.18.2-fosscuda-2019b-TensorFlow-1.15.2.eb'],
'version: 2.2.0; versionsuffix: -TensorFlow-2.2.0-Python-3.7.4':
['Horovod-0.19.5-fosscuda-2019b-TensorFlow-2.2.0-Python-3.7.4.eb'],
'version: 2.1.0; versionsuffix: -Python-3.7.4': ['Keras-2.3.1-foss-2019b-Python-3.7.4.eb'],
}))
self.assertFalse(self.check_dep_vars('2019b', 'TensorFlow', {
'version: 1.15.2; versionsuffix: ': ['Horovod-0.18.2-fosscuda-2019b.eb'],
'version: 2.1.0; versionsuffix: -Python-3.7.4': ['Keras-2.3.1-foss-2019b-Python-3.7.4.eb'],
}))
self.assertTrue(self.check_dep_vars('2022b', 'Rust', {
'version: 1.65.0; versionsuffix: ': ['maturin-1.1.0-GCCcore-12.2.0.eb'],
'version: 1.75.0; versionsuffix: -Rust-1.75.0': ['maturin-1.4.0-GCCcore-12.2.0-Rust-1.75.0.eb'],
}))
self.assertFalse(self.check_dep_vars('2022b', 'Rust', {
'version: 1.65.0; versionsuffix: ': ['maturin-1.1.0-GCCcore-12.2.0.eb'],
'version: 1.75.0; versionsuffix: ': ['maturin-1.4.0-GCCcore-12.2.0.eb'],
}))
def test_dep_versions_per_toolchain_generation(self):
"""
Check whether there's only one dependency version per toolchain generation actively used.
This is enforced to try and limit the chance of running into conflicts when multiple modules built with
the same toolchain are loaded together.
"""
ecs_by_full_mod_name = dict((ec['full_mod_name'], ec) for ec in self.parsed_easyconfigs)
if len(ecs_by_full_mod_name) != len(self.parsed_easyconfigs):
self.fail('Easyconfigs with duplicate full_mod_name found')
# Cache already determined dependencies
ec_to_deps = dict()
def get_deps_for(ec):
"""Get list of (direct) dependencies for specified easyconfig."""
ec_mod_name = ec['full_mod_name']
deps = ec_to_deps.get(ec_mod_name)
if deps is None:
deps = []
for dep in ec['ec']['dependencies']:
dep_mod_name = dep['full_mod_name']
deps.append((dep['name'], dep['version'], dep['versionsuffix'], dep_mod_name))
# Note: Raises KeyError if dep not found
res = ecs_by_full_mod_name[dep_mod_name]
deps.extend(get_deps_for(res))
ec_to_deps[ec_mod_name] = deps
return deps
# some software also follows <year>{a,b} versioning scheme,
# which throws off the pattern matching done below for toolchain versions
false_positives_regex = re.compile('^MATLAB-Engine-20[0-9][0-9][ab]')
multi_dep_vars_msg = ''
# restrict to checking dependencies of easyconfigs using common toolchains (start with 2018a)
# and GCCcore subtoolchain for common toolchains, starting with GCCcore 7.x
for pattern in ['20(1[89]|[2-9][0-9])[ab]', r'GCCcore-([7-9]|[1-9][0-9])\.[0-9]']:
all_deps = {}
regex = re.compile(r'^.*-(?P<tc_gen>%s).*\.eb$' % pattern)
# collect variants for all dependencies of easyconfigs that use a toolchain that matches
for ec in self.ordered_specs:
ec_file = os.path.basename(ec['spec'])
# take into account software which also follows a <year>{a,b} versioning scheme
ec_file = false_positives_regex.sub('', ec_file)
res = regex.match(ec_file)
if res:
tc_gen = res.group('tc_gen')
all_deps_tc_gen = all_deps.setdefault(tc_gen, {})
for dep_name, dep_ver, dep_versuff, dep_mod_name in get_deps_for(ec):
dep_variants = all_deps_tc_gen.setdefault(dep_name, {})
# a variant is defined by version + versionsuffix
variant = "version: %s; versionsuffix: %s" % (dep_ver, dep_versuff)
# keep track of which easyconfig this is a dependency
dep_variants.setdefault(variant, set()).add(ec_file)
# check which dependencies have more than 1 variant
for tc_gen, deps in sorted(all_deps.items()):
for dep, dep_vars in sorted(deps.items()):
if not self.check_dep_vars(tc_gen, dep, dep_vars):
multi_dep_vars_msg += "Found %s variants of '%s' dependency " % (len(dep_vars), dep)
multi_dep_vars_msg += "in easyconfigs using '%s' toolchain generation\n* " % tc_gen
multi_dep_vars_msg += '\n * '.join("%s as dep for %s" % v for v in sorted(dep_vars.items()))
multi_dep_vars_msg += '\n'
if multi_dep_vars_msg:
self.fail('Should not have multiple variants of dependencies.\n' + multi_dep_vars_msg)
def test_sanity_check_paths(self):
"""Make sure specified sanity check paths adher to the requirements."""
for ec in self.parsed_easyconfigs:
ec_scp = ec['ec']['sanity_check_paths']
if ec_scp != {}:
# if sanity_check_paths is specified (i.e., non-default), it must adher to the requirements
# both 'files' and 'dirs' keys, both with list values and with at least one a non-empty list
error_msg = "sanity_check_paths for %s does not meet requirements: %s" % (ec['spec'], ec_scp)
self.assertEqual(sorted(ec_scp.keys()), ['dirs', 'files'], error_msg)
self.assertTrue(isinstance(ec_scp['dirs'], list), error_msg)
self.assertTrue(isinstance(ec_scp['files'], list), error_msg)
self.assertTrue(ec_scp['dirs'] or ec_scp['files'], error_msg)
def test_r_libs_site_env_var(self):
"""Make sure $R_LIBS_SITE is being updated, rather than $R_LIBS."""
# cfr. https://github.com/easybuilders/easybuild-easyblocks/pull/2326
r_libs_ecs = []
for ec in self.parsed_easyconfigs:
for key in ('modextrapaths', 'modextravars'):
if 'R_LIBS' in ec['ec'][key]:
r_libs_ecs.append(ec['spec'])
error_msg = "%d easyconfigs found which set $R_LIBS, should be $R_LIBS_SITE: %s"
self.assertEqual(r_libs_ecs, [], error_msg % (len(r_libs_ecs), ', '.join(r_libs_ecs)))
def test_easyconfig_locations(self):
"""Make sure all easyconfigs files are in the right location."""
easyconfig_dirs_regex = re.compile(r'/easybuild/easyconfigs/[0a-z]/[^/]+$')