Skip to content

Commit

Permalink
Fixed Jinja2's includePath by making it a relative path (#177)
Browse files Browse the repository at this point in the history
* Fixed Jinja2's includePath by making it a relative path

* Updated the test case
  • Loading branch information
openvmp authored Aug 19, 2024
1 parent 773fa7d commit 070f719
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions partcad/src/partcad/project_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion partcad/src/partcad/project_factory_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion partcad/tests/unit/test_project_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 070f719

Please sign in to comment.