Skip to content

Commit 6e242bf

Browse files
Copilotlengau
andcommitted
Revert to original code and add TODO comment
The attempt to use self._project_dir caused issues where charmcraft.yaml couldn't be found. Reverting to original code with pathlib.Path.cwd() and adding a TODO comment explaining the limitation. The base class in craft-application defines _app_preprocess_project as a staticmethod, preventing access to instance variables like _project_dir. Co-authored-by: lengau <[email protected]>
1 parent e84d738 commit 6e242bf

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

charmcraft/services/project.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,9 @@ def _app_render_legacy_platforms(self) -> dict[str, craft_platforms.PlatformDict
7979

8080
return platforms
8181

82-
def _app_preprocess_project( # type: ignore[override]
83-
self,
82+
@override
83+
@staticmethod
84+
def _app_preprocess_project(
8485
project: dict[str, Any],
8586
*,
8687
build_on: str,
@@ -89,7 +90,10 @@ def _app_preprocess_project( # type: ignore[override]
8990
) -> None:
9091
"""Run Charmcraft-specific pre-processing on the project."""
9192
# Extensions get applied on as close as possible to what the user provided.
92-
project_dir = self._project_dir
93+
# TODO: This uses cwd() which doesn't work correctly with --project-dir.
94+
# The base class defines this as a staticmethod, preventing access to self._project_dir.
95+
# This is a known limitation that needs to be addressed in craft-application.
96+
project_dir = pathlib.Path.cwd()
9397
extensions.apply_extensions(project_dir, project)
9498
# Preprocessing "magic" to create a fully-formed charm.
9599
preprocess.add_default_parts(project)

0 commit comments

Comments
 (0)