Skip to content

Commit

Permalink
build: use optional_dependencies (#177)
Browse files Browse the repository at this point in the history
Signed-off-by: nstarman <nstarman@users.noreply.github.com>
  • Loading branch information
nstarman authored Sep 9, 2024
1 parent f4a242c commit 682e788
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"jax",
"jaxlib",
"jaxtyping",
"optional_dependencies >= 0.1",
"plum-dispatch>=2.5.1",
"quax>=0.0.3",
"quaxed >= 0.4",
Expand Down
4 changes: 2 additions & 2 deletions src/coordinax/_interop/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

__all__: list[str] = []

from . import optional_deps
from .optional_deps import OptDeps

if optional_deps.HAS_ASTROPY:
if OptDeps.ASTROPY.is_installed:
from . import coordinax_interop_astropy # noqa: F401
10 changes: 7 additions & 3 deletions src/coordinax/_interop/optional_deps.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
"""Optional dependencies. Internal use only."""

__all__ = ["HAS_ASTROPY"]
__all__ = ["OptDeps"]

from importlib.util import find_spec
from optional_dependencies import OptionalDependencyEnum, auto

HAS_ASTROPY: bool = find_spec("astropy") is not None

class OptDeps(OptionalDependencyEnum): # type: ignore[misc]
"""Optional dependencies for ``coordinax``."""

ASTROPY = auto()

0 comments on commit 682e788

Please sign in to comment.