Skip to content

Commit 4e2a8f9

Browse files
committed
PR#24761: fix EVcouplings v0.2.1 comptability with ruamel.yaml 0.18
1 parent 96b933a commit 4e2a8f9

File tree

2 files changed

+103
-4
lines changed

2 files changed

+103
-4
lines changed

easyconfigs/e/EVcouplings/EVcouplings-0.2.1-foss-2024a.eb

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,25 @@ exts_list = [
3939
('evcouplings', version, {
4040
'source_urls': [GITHUB_SOURCE],
4141
'sources': ['v%(version)s.tar.gz'],
42-
'checksums': ['7ff44cdbc14b7319ceef5fa50801edf78aea4892bec04475517763a6d46bd058'],
42+
'patches': ['EVcouplings-0.2.1_update-ruamel-api.patch'],
43+
'checksums': [
44+
{'v0.2.1.tar.gz': '7ff44cdbc14b7319ceef5fa50801edf78aea4892bec04475517763a6d46bd058'},
45+
{'EVcouplings-0.2.1_update-ruamel-api.patch':
46+
'7e21635a7dba75fba7e0b2b5f4a63a00a3634e207f630506d7895ecceb76cf2b'},
47+
],
4348
# relax version requirement on ruamel.yaml
4449
'preinstallopts': "sed -i 's/ruamel.yaml<0.18/ruamel.yaml/' pyproject.toml &&",
4550
}),
4651
]
4752

48-
modextrapaths = {
49-
'EVCOUPLINGS_RUNCFG_APP': 'bin/evcouplings_runcfg',
50-
'EVCOUPLINGS_SUMMARIZE_APP': 'bin/evcouplings_summarize',
53+
modextravars = {
54+
'EVCOUPLINGS_RUNCFG_APP': '%(installdir)s/bin/evcouplings_runcfg',
55+
'EVCOUPLINGS_SUMMARIZE_APP': '%(installdir)s/bin/evcouplings_summarize',
56+
}
57+
58+
sanity_check_paths = {
59+
'files': ['bin/evcouplings', 'bin/evcouplings_runcfg', 'bin/evcouplings_summarize'],
60+
'dirs': ['lib/python%(pyshortver)s/site-packages/'],
5161
}
5262

5363
sanity_check_commands = [
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
update to new API in ruamel.yaml version 0.18
2+
see https://github.com/debbiemarkslab/EVcouplings/pull/333
3+
author: Alex Domingo (Vrije Universiteit Brussel)
4+
diff --git a/evcouplings/utils/config.py b/evcouplings/utils/config.py
5+
index fe8fb67..163f31f 100644
6+
--- a/evcouplings/utils/config.py
7+
+++ b/evcouplings/utils/config.py
8+
@@ -10,7 +10,8 @@ Authors:
9+
Thomas A. Hopf
10+
"""
11+
12+
-import ruamel.yaml as yaml
13+
+from ruamel.yaml import YAML
14+
+from ruamel.yaml.error import MarkedYAMLError
15+
16+
17+
class MissingParameterError(Exception):
18+
@@ -25,7 +26,7 @@ class InvalidParameterError(Exception):
19+
"""
20+
21+
22+
-def parse_config(config_str, preserve_order=False):
23+
+def parse_config(config_str):
24+
"""
25+
Parse a configuration string
26+
27+
@@ -33,29 +34,25 @@ def parse_config(config_str, preserve_order=False):
28+
----------
29+
config_str : str
30+
Configuration to be parsed
31+
- preserve_order : bool, optional (default: True)
32+
- Preserve formatting of input configuration
33+
- string
34+
35+
Returns
36+
-------
37+
dict
38+
Configuration dictionary
39+
"""
40+
+ # uses round-trip loader by default, preserving order
41+
+ yaml = YAML(typ='safe', pure=True)
42+
try:
43+
- if preserve_order:
44+
- return yaml.load(config_str, Loader=yaml.RoundTripLoader)
45+
- else:
46+
- return yaml.safe_load(config_str)
47+
- except yaml.parser.ParserError as e:
48+
+ return yaml.load(config_str)
49+
+ except MarkedYAMLError as e:
50+
raise InvalidParameterError(
51+
"Could not parse input configuration. "
52+
"Formatting mistake in config file? "
53+
- "See ParserError above for details."
54+
+ "See MarkedYAMLError above for details."
55+
) from e
56+
57+
58+
-def read_config_file(filename, preserve_order=False):
59+
+def read_config_file(filename):
60+
"""
61+
Read and parse a configuration file.
62+
63+
@@ -70,7 +67,7 @@ def read_config_file(filename, preserve_order=False):
64+
Configuration dictionary
65+
"""
66+
with open(filename) as f:
67+
- return parse_config(f, preserve_order)
68+
+ return parse_config(f)
69+
70+
71+
def write_config_file(out_filename, config):
72+
@@ -84,14 +81,11 @@ def write_config_file(out_filename, config):
73+
config : dict
74+
Config data that will be written to file
75+
"""
76+
- if isinstance(config, yaml.comments.CommentedBase):
77+
- dumper = yaml.RoundTripDumper
78+
- else:
79+
- dumper = yaml.Dumper
80+
-
81+
+ yaml = YAML(typ='safe', pure=True)
82+
+ yaml.default_flow_style = False
83+
with open(out_filename, "w") as f:
84+
f.write(
85+
- yaml.dump(config, Dumper=dumper, default_flow_style=False)
86+
+ yaml.dump(config)
87+
)
88+
89+

0 commit comments

Comments
 (0)