Source code for jitx.project

"""Discover the JITX project and metadata.

.. admonition:: Experimental

    This package is experimental and may change.
"""

from __future__ import annotations

from pathlib import Path

from jitx.run.pyproject import PyProject


[docs] class NotAJitxProject(Exception): """This does not appear to be a JITX project.""" def __init__( self, message: str, *, search_start: str | Path, pyproject: Path | None, ) -> None: super().__init__(message) self.search_start = search_start self.pyproject = pyproject
[docs] class JitxProject(PyProject): """An object representing a JITX project and its metadata.""" root: Path def __init__(self, start: Path | str = "."): super().__init__(start) if not self.path: raise NotAJitxProject( "Could not find a project root.", search_start=start, pyproject=None ) self.root = self.path.parent
[docs] def discover(start: Path | str = ".") -> JitxProject: """Determine the Jitx project given a path somewhere inside the project. Raises an execption if no project is found.""" return JitxProject(start)