From 070f7190036fc6fb53e4c06222b650e3af45d07f Mon Sep 17 00:00:00 2001 From: OpenVMP Date: Sun, 18 Aug 2024 21:58:54 -0700 Subject: [PATCH] Fixed Jinja2's includePath by making it a relative path (#177) * Fixed Jinja2's includePath by making it a relative path * Updated the test case --- partcad/src/partcad/project_config.py | 3 +++ partcad/src/partcad/project_factory_local.py | 4 +++- partcad/tests/unit/test_project_config.py | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/partcad/src/partcad/project_config.py b/partcad/src/partcad/project_config.py index 7f5f900a..fa8eb4c1 100644 --- a/partcad/src/partcad/project_config.py +++ b/partcad/src/partcad/project_config.py @@ -57,6 +57,9 @@ def __init__( loaders = [FileSystemLoader(self.config_dir + os.path.sep)] # TODO(clairbee): mark the build as non-hermetic if includePaths is used for include_path in include_paths: + include_path = ( + os.path.join(self.config_dir, include_path) + os.path.sep + ) loaders.append(FileSystemLoader(include_path)) loader = ChoiceLoader(loaders) template = Environment(loader=loader).from_string(config) diff --git a/partcad/src/partcad/project_factory_local.py b/partcad/src/partcad/project_factory_local.py index 9747c18a..bbd11b42 100644 --- a/partcad/src/partcad/project_factory_local.py +++ b/partcad/src/partcad/project_factory_local.py @@ -13,7 +13,9 @@ class LocalImportConfiguration: def __init__(self): - self.import_config_path = self.config_obj.get("path") + self.import_config_path = self.config_obj.get("path").replace( + "/", os.path.sep + ) self.maybe_empty = False if "maybeEmpty" in self.config_obj: self.maybe_empty = self.config_obj.get("maybeEmpty") diff --git a/partcad/tests/unit/test_project_config.py b/partcad/tests/unit/test_project_config.py index 09f09c23..037ed8a0 100644 --- a/partcad/tests/unit/test_project_config.py +++ b/partcad/tests/unit/test_project_config.py @@ -57,7 +57,7 @@ def test_project_config_template_override(): "name": "/that", "type": "local", "path": "unit/data/project_config_include.yaml", - "includePaths": ["partcad/tests/unit/data/subdir"], + "includePaths": ["subdir"], }, ) # In this test case, the template is used to name the part the same name as