Skip to content

Commit af77308

Browse files
authored
Merge pull request #2 from nv-legate/jacobf/2025-04-29/remove-in-suffix
Remove the .in suffix from config template files
2 parents 1e225fd + 1b766b0 commit af77308

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

src/aedifix/config.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class ConfigFile(Configurable):
2929
"_cmake_configure_file",
3030
"_config_file_template",
3131
"_default_subst",
32+
"_project_variables_file",
3233
)
3334

3435
def __init__(
@@ -45,6 +46,13 @@ def __init__(
4546
"""
4647
super().__init__(manager=manager)
4748
self._config_file_template = config_file_template.resolve()
49+
50+
config_file = self.template_file
51+
if config_file.suffix == ".in":
52+
# remove the trailing .in
53+
config_file = config_file.with_suffix("")
54+
55+
self._project_variables_file = self.project_arch_dir / config_file.name
4856
self._default_subst = {"PYTHON_EXECUTABLE": sys.executable}
4957

5058
@property
@@ -72,7 +80,7 @@ def project_variables_file(self) -> Path:
7280
The file is not guaranteed to exist, or be up to date. Usually it is
7381
created/refreshed during finalization of this object.
7482
"""
75-
return self.project_arch_dir / "gmakevariables"
83+
return self._project_variables_file
7684

7785
def _read_entire_cmake_cache(self, cmake_cache: Path) -> dict[str, str]:
7886
r"""Read a CMakeCache.txt and convert all of the cache values to
@@ -164,7 +172,7 @@ def finalize(self) -> None:
164172
If the user config file contains an unknown AEDIFIX substitution.
165173
"""
166174
project_file = self.project_variables_file
167-
template_file = self._config_file_template
175+
template_file = self.template_file
168176
self.log(f"Using project file: {project_file}")
169177
self.log(f"Using template file: {template_file}")
170178

tests/test_config.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,29 @@ def test_create(self, manager: DummyManager, tmp_path: Path) -> None:
3232
assert config.template_file.exists()
3333
assert config.template_file.is_file()
3434
assert config.template_file == template
35-
35+
assert (
36+
config.project_variables_file.name == template.with_suffix("").name
37+
)
3638
assert config._default_subst == {"PYTHON_EXECUTABLE": sys.executable}
3739

40+
@pytest.mark.parametrize(
41+
("base", "expected"),
42+
(
43+
("foo.bar.baz.in", "foo.bar.baz"),
44+
("foo.bar", "foo.bar"),
45+
("foo", "foo"),
46+
),
47+
)
48+
def test_project_variables_file(
49+
self, manager: DummyManager, tmp_path: Path, base: str, expected: str
50+
) -> None:
51+
template = tmp_path / base
52+
template.touch()
53+
54+
config = ConfigFile(manager=manager, config_file_template=template)
55+
56+
assert config.project_variables_file.name == expected
57+
3858

3959
if __name__ == "__main__":
4060
sys.exit(pytest.main())

0 commit comments

Comments
 (0)