From 18b70dd2db8636d91a63326abc541531cbaa1fb6 Mon Sep 17 00:00:00 2001 From: Joaquin Matres <4514346+joamatab@users.noreply.github.com> Date: Wed, 1 Mar 2023 21:35:57 -0800 Subject: [PATCH] gf version shows versions of all plugins --- README.md | 2 +- gdsfactory/cli.py | 22 ++++++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 5f8411ff44..ac3545e318 100644 --- a/README.md +++ b/README.md @@ -140,7 +140,7 @@ Or you can install only the ones you need. * Eigenmode Expansion (EME) - [MEOW](https://gdsfactory.github.io/gdsfactory/notebooks/eme/01_meow.html) * [Electromagnetic Wave Solvers using Finite Difference Time Domain (FDTD)](https://gdsfactory.github.io/gdsfactory/plugins_fdtd.html) - - [tid3d](https://gdsfactory.github.io/gdsfactory/notebooks/tidy3d/00_tidy3d.html) + - [tidy3d](https://gdsfactory.github.io/gdsfactory/notebooks/tidy3d/00_tidy3d.html) - [MEEP](https://gdsfactory.github.io/gdsfactory/notebooks/meep/001_meep_sparameters.html) - [Ansys Lumerical FDTD](https://gdsfactory.github.io/gdsfactory/notebooks/lumerical/1_fdtd_sparameters.html) * [S-Parameter Circuit Solvers](https://gdsfactory.github.io/gdsfactory/plugins_circuits.html) diff --git a/gdsfactory/cli.py b/gdsfactory/cli.py index e6aa887994..1a1fa3e061 100644 --- a/gdsfactory/cli.py +++ b/gdsfactory/cli.py @@ -20,17 +20,30 @@ LAYER_LABEL = LAYER.LABEL +plugins = ["ray", "femwell", "devsim", "tidy3d", "meep", "meow", "lumapi", "sax"] + + def print_version(ctx: Context, param: Option, value: bool) -> None: """Prints the version.""" if not value or ctx.resilient_parsing: return - click.echo(VERSION) + click.echo(f"gdsfactory {VERSION}") + for plugin in plugins: + try: + import importlib + + m = importlib.import_module(plugin) + try: + click.echo(f"{plugin} {m.__version__}") + except AttributeError: + click.echo(f"{plugin} installed") + except ImportError: + click.echo(f"{plugin} not installed") + ctx.exit() # TOOL - - @click.group() def tool() -> None: """Commands working with gdsfactory tool.""" @@ -178,4 +191,5 @@ def cli(name="gf") -> None: if __name__ == "__main__": - cli() + # cli() + print_version()