diff --git a/pyproject.toml b/pyproject.toml index f9417bf..49a5ad8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ build-backend = "setuptools.build_meta" [project] name = "aedifix" authors = [{name = "NVIDIA Corporation"}] -license = { text = "Apache-2.0" } +license = "Apache-2.0" description = "aedifix - Build system for Legate libraries" classifiers = [ "Intended Audience :: Developers", diff --git a/src/aedifix/config.py b/src/aedifix/config.py index 248c237..afc508d 100644 --- a/src/aedifix/config.py +++ b/src/aedifix/config.py @@ -26,7 +26,6 @@ class ConfigFile(Configurable): """ __slots__ = ( - "_cmake_configure_file", "_config_file_template", "_default_subst", "_project_variables_file", @@ -42,7 +41,7 @@ def __init__( manager : ConfigurationManager The configuration manager to manage this Config. config_file_template : Path - The template file to read + The template file to read. """ super().__init__(manager=manager) self._config_file_template = config_file_template.resolve() diff --git a/src/aedifix/package/main_package.py b/src/aedifix/package/main_package.py index 5be9522..e060e7d 100644 --- a/src/aedifix/package/main_package.py +++ b/src/aedifix/package/main_package.py @@ -372,7 +372,7 @@ def __init__( # noqa: PLR0913 arch_name: str, project_dir_name: str, project_dir_value: Path, - project_config_file_template: Path, + project_config_file_template: Path | None = None, project_src_dir: Path | None = None, default_arch_file_path: Path | None = None, ) -> None: @@ -390,9 +390,11 @@ def __init__( # noqa: PLR0913 The name of the project dir variable, e.g. 'LEGATE_DIR'. project_dir_value : Path The value of the project dir, e.g. /path/to/legate. - project_config_file_template: Path + project_config_file_template: Path, optional A path to a configure file template to fill out and place under - PROJECT_DIR/PROJECT_ARCH on successful configure. + PROJECT_DIR/PROJECT_ARCH on successful configure. If not given, + a default template file containing PYTHON, CMAKE, + CMAKE_BUILD_PARALLEL_LEVEL, and CMAKE_GENERATOR will be used. project_src_dir : Path, optional The path to the projects source directory for CMake. If not provided, ``project_dir_value`` is used instead. @@ -414,6 +416,11 @@ def __init__( # noqa: PLR0913 assert not arch_name.endswith("_") assert arch_name.isupper() assert arch_name.endswith("ARCH") + if project_config_file_template is None: + project_config_file_template = ( + Path(__file__).parents[1] / "templates" / "variables.mk.in" + ).resolve(strict=True) + if not project_config_file_template.exists(): msg = ( f"Project configure file: {project_config_file_template} does " @@ -426,6 +433,7 @@ def __init__( # noqa: PLR0913 "not a file" ) raise ValueError(msg) + self._arch_name = arch_name self._arch_value, self._arch_value_provenance = ( self.preparse_arch_value(argv) @@ -441,9 +449,7 @@ def __init__( # noqa: PLR0913 raise ValueError(msg) self._proj_dir_name = project_dir_name self._proj_dir_value = project_dir_value.resolve(strict=True) - self._proj_config_file_template = ( - project_config_file_template.resolve() - ) + self._proj_config_file_template = project_config_file_template if project_src_dir is None: project_src_dir = self._proj_dir_value self._proj_src_dir = project_src_dir.resolve(strict=True) diff --git a/src/aedifix/templates/variables.mk.in b/src/aedifix/templates/variables.mk.in new file mode 100644 index 0000000..7275eb2 --- /dev/null +++ b/src/aedifix/templates/variables.mk.in @@ -0,0 +1,5 @@ +# -*- mode: makefile-gmake -*- +export PYTHON ?= @AEDIFIX_PYTHON_EXECUTABLE@ +export CMAKE ?= @CMAKE_COMMAND@ +export CMAKE_BUILD_PARALLEL_LEVEL ?= @CMAKE_BUILD_PARALLEL_LEVEL@ +export CMAKE_GENERATOR ?= @CMAKE_GENERATOR@ diff --git a/tests/fixtures/dummy_main_module.py b/tests/fixtures/dummy_main_module.py index 186a742..c3c7f22 100644 --- a/tests/fixtures/dummy_main_module.py +++ b/tests/fixtures/dummy_main_module.py @@ -5,8 +5,7 @@ from os import environ from pathlib import Path -from tempfile import NamedTemporaryFile -from typing import TYPE_CHECKING, Final +from typing import TYPE_CHECKING from .dummy_main_package import DummyMainPackage @@ -15,9 +14,6 @@ from aedifix.manager import ConfigurationManager -_tmp_file: Final = NamedTemporaryFile() # noqa: SIM115 -_tmp_path: Final = Path(_tmp_file.name) - class DummyMainModule(DummyMainPackage): name = "DummyMainModule" @@ -31,7 +27,6 @@ def __init__( arch_name="AEDIFIX_PYTEST_ARCH", project_dir_name="AEDIFIX_PYTEST_DIR", project_dir_value=Path(environ["AEDIFIX_PYTEST_DIR"]), - project_config_file_template=_tmp_path, ) @classmethod diff --git a/tests/test_manager.py b/tests/test_manager.py index ba38762..216cffa 100644 --- a/tests/test_manager.py +++ b/tests/test_manager.py @@ -28,11 +28,6 @@ from pathlib import Path -@pytest.fixture -def manager() -> ConfigurationManager: - return ConfigurationManager((), DummyMainModule) - - class TestConfigurationManager: @pytest.mark.parametrize( "argv", ((), ("--foo",), ("-b", "1", "--bar=baz")) @@ -79,9 +74,8 @@ def test_create( assert (manager._aedifix_root_dir / "aedifix").exists() assert (manager._aedifix_root_dir / "aedifix").is_dir() - def test_setup( - self, manager: ConfigurationManager, AEDIFIX_PYTEST_ARCH: str - ) -> None: + def test_setup(self, AEDIFIX_PYTEST_ARCH: str) -> None: + manager = ConfigurationManager((), DummyMainModule) orig_argv = deepcopy(manager.argv) assert len(manager._modules) == 1 manager.setup()