@@ -173,7 +173,7 @@ def at_least_one_target(cls, values):
173173 ] = False
174174
175175 input_file : Annotated [
176- Path , Field (description = "Project metadata input file path." )
176+ Optional [ Path ] , Field (description = "Project metadata input file path." )
177177 ] = Path ("somesy.toml" )
178178
179179 no_sync_pyproject : Annotated [
@@ -249,6 +249,14 @@ def at_least_one_target(cls, values):
249249 Field (description = "Pass validation for all output files." ),
250250 ] = False
251251
252+ # packages (sub-folders) for monorepos with their own somesy config
253+ packages : Annotated [
254+ Optional [Union [Path , List [Path ]]],
255+ Field (
256+ description = "Packages (sub-folders) for monorepos with their own somesy config."
257+ ),
258+ ] = None
259+
252260 def log_level (self ) -> SomesyLogLevel :
253261 """Return log level derived from this configuration."""
254262 return SomesyLogLevel .from_flags (
@@ -272,6 +280,37 @@ def get_input(self) -> SomesyInput:
272280 somesy_input .config = SomesyConfig (** dct )
273281 return somesy_input
274282
283+ def resolve_paths (self , base_dir : Path ) -> None :
284+ """Resolve all paths in the config relative to the given base directory.
285+
286+ Args:
287+ base_dir: The base directory to resolve paths against.
288+
289+ """
290+
291+ def resolve_path (
292+ paths : Optional [Union [Path , List [Path ]]],
293+ ) -> Optional [Union [Path , List [Path ]]]:
294+ if paths is None :
295+ return None
296+ if isinstance (paths , list ):
297+ return [base_dir / p for p in paths ]
298+ return base_dir / paths
299+
300+ # Resolve all file paths
301+ resolved_input = resolve_path (self .input_file )
302+ self .input_file = resolved_input if isinstance (resolved_input , Path ) else None
303+ self .pyproject_file = resolve_path (self .pyproject_file )
304+ self .package_json_file = resolve_path (self .package_json_file )
305+ self .julia_file = resolve_path (self .julia_file )
306+ self .fortran_file = resolve_path (self .fortran_file )
307+ self .pom_xml_file = resolve_path (self .pom_xml_file )
308+ self .mkdocs_file = resolve_path (self .mkdocs_file )
309+ self .rust_file = resolve_path (self .rust_file )
310+ self .cff_file = resolve_path (self .cff_file )
311+ self .codemeta_file = resolve_path (self .codemeta_file )
312+ self .packages = resolve_path (self .packages )
313+
275314
276315# --------
277316# Project metadata model (modified from CITATION.cff)
@@ -735,6 +774,13 @@ class SomesyInput(SomesyBaseModel):
735774 ),
736775 ]
737776
777+ # if config.input_file is set, use it as origin
778+ @model_validator (mode = "after" )
779+ def set_origin (self ):
780+ """Set the origin of the input file."""
781+ if self .config and self .config .input_file :
782+ self ._origin = self .config .input_file
783+
738784 def is_somesy_file (self ) -> bool :
739785 """Return whether this somesy input is from a somesy config file.
740786
0 commit comments