From 68262c31774266ad640c35831b917520e3693a02 Mon Sep 17 00:00:00 2001 From: Jacob Faibussowitsch Date: Tue, 29 Apr 2025 16:00:14 -0400 Subject: [PATCH 1/4] Remove the .in suffix from config template files --- src/aedifix/config.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/aedifix/config.py b/src/aedifix/config.py index 2833fba..1546ebd 100644 --- a/src/aedifix/config.py +++ b/src/aedifix/config.py @@ -28,6 +28,7 @@ class ConfigFile(Configurable): __slots__ = ( "_cmake_configure_file", "_config_file_template", + "_project_variables_file", "_default_subst", ) @@ -45,6 +46,14 @@ def __init__( """ super().__init__(manager=manager) self._config_file_template = config_file_template.resolve() + + config_file = self.template_file.name + if config_file.suffix == ".in": + config_file = config_file.with_suffix( + "" + ) # removes the trailing .in + + self._project_variables_file = self.project_arch_dir / config_file self._default_subst = {"PYTHON_EXECUTABLE": sys.executable} @property @@ -72,7 +81,7 @@ def project_variables_file(self) -> Path: The file is not guaranteed to exist, or be up to date. Usually it is created/refreshed during finalization of this object. """ - return self.project_arch_dir / "gmakevariables" + return self._project_variables_file def _read_entire_cmake_cache(self, cmake_cache: Path) -> dict[str, str]: r"""Read a CMakeCache.txt and convert all of the cache values to From 66e6cf7414045bda111ba61f0dd3bb9d3bb68fd1 Mon Sep 17 00:00:00 2001 From: Jacob Faibussowitsch Date: Tue, 29 Apr 2025 16:11:54 -0400 Subject: [PATCH 2/4] fixup! Remove the .in suffix from config template files --- src/aedifix/config.py | 8 ++++---- tests/test_config.py | 22 +++++++++++++++++++++- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/aedifix/config.py b/src/aedifix/config.py index 1546ebd..71434b0 100644 --- a/src/aedifix/config.py +++ b/src/aedifix/config.py @@ -28,8 +28,8 @@ class ConfigFile(Configurable): __slots__ = ( "_cmake_configure_file", "_config_file_template", - "_project_variables_file", "_default_subst", + "_project_variables_file", ) def __init__( @@ -47,13 +47,13 @@ def __init__( super().__init__(manager=manager) self._config_file_template = config_file_template.resolve() - config_file = self.template_file.name + config_file = self.template_file if config_file.suffix == ".in": config_file = config_file.with_suffix( "" ) # removes the trailing .in - self._project_variables_file = self.project_arch_dir / config_file + self._project_variables_file = self.project_arch_dir / config_file.name self._default_subst = {"PYTHON_EXECUTABLE": sys.executable} @property @@ -173,7 +173,7 @@ def finalize(self) -> None: If the user config file contains an unknown AEDIFIX substitution. """ project_file = self.project_variables_file - template_file = self._config_file_template + template_file = self.template_file self.log(f"Using project file: {project_file}") self.log(f"Using template file: {template_file}") diff --git a/tests/test_config.py b/tests/test_config.py index 7f2d67a..9b68b6b 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -32,9 +32,29 @@ def test_create(self, manager: DummyManager, tmp_path: Path) -> None: assert config.template_file.exists() assert config.template_file.is_file() assert config.template_file == template - + assert ( + config.project_variables_file.name == template.with_suffix("").name + ) assert config._default_subst == {"PYTHON_EXECUTABLE": sys.executable} + @pytest.mark.parametrize( + ("base", "expected"), + ( + ("foo.bar.baz.in", "foo.bar.baz"), + ("foo.bar", "foo.bar"), + ("foo", "foo"), + ), + ) + def test_project_variables_file( + self, manager: DummyManager, tmp_path: Path, base: str, expected: str + ) -> None: + template = tmp_path / base + template.touch() + + config = ConfigFile(manager=manager, config_file_template=template) + + assert config.project_variables_file.name == expected + if __name__ == "__main__": sys.exit(pytest.main()) From 77ceedac2dfa02e159a88a62f1acf5fb012569e1 Mon Sep 17 00:00:00 2001 From: Jacob Faibussowitsch Date: Tue, 29 Apr 2025 17:03:13 -0400 Subject: [PATCH 3/4] Update src/aedifix/config.py Co-authored-by: Bryan Van de Ven --- src/aedifix/config.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/aedifix/config.py b/src/aedifix/config.py index 71434b0..61eae59 100644 --- a/src/aedifix/config.py +++ b/src/aedifix/config.py @@ -49,9 +49,8 @@ def __init__( config_file = self.template_file if config_file.suffix == ".in": - config_file = config_file.with_suffix( - "" - ) # removes the trailing .in + # remove the trailing .in + config_file = config_file.with_suffix("") self._project_variables_file = self.project_arch_dir / config_file.name self._default_subst = {"PYTHON_EXECUTABLE": sys.executable} From 1b766b0ef0b7504df03e359ff7fbe806c48d21f9 Mon Sep 17 00:00:00 2001 From: Jacob Faibussowitsch Date: Tue, 29 Apr 2025 17:03:46 -0400 Subject: [PATCH 4/4] fixup! Update src/aedifix/config.py --- src/aedifix/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/aedifix/config.py b/src/aedifix/config.py index 61eae59..248c237 100644 --- a/src/aedifix/config.py +++ b/src/aedifix/config.py @@ -50,7 +50,7 @@ def __init__( config_file = self.template_file if config_file.suffix == ".in": # remove the trailing .in - config_file = config_file.with_suffix("") + config_file = config_file.with_suffix("") self._project_variables_file = self.project_arch_dir / config_file.name self._default_subst = {"PYTHON_EXECUTABLE": sys.executable}