From 21de7890f8e895ab9931ab8b93b03b23dbccaa61 Mon Sep 17 00:00:00 2001 From: David Linke Date: Sat, 17 Aug 2024 00:37:27 +0200 Subject: [PATCH 1/2] Add version option to cli and dynamic versioning --- pyproject.toml | 7 +++++-- schema_automator/__init__.py | 8 ++++++++ schema_automator/cli.py | 2 ++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index bdafe7d..2892e94 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,8 +48,11 @@ lxml = ">=4.9.1" llm = ">=0.12" [build-system] -requires = ["poetry-core>=1.0.0"] -build-backend = "poetry.core.masonry.api" +requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning>=1.0.0,<2.0.0"] +build-backend = "poetry_dynamic_versioning.backend" + +[tool.poetry-dynamic-versioning] +enable = true [tool.poetry.scripts] schemauto = "schema_automator.cli:main" diff --git a/schema_automator/__init__.py b/schema_automator/__init__.py index 2eadd7a..0cfc39b 100644 --- a/schema_automator/__init__.py +++ b/schema_automator/__init__.py @@ -1,3 +1,11 @@ +from importlib import metadata + from schema_automator.annotators import * from schema_automator.importers import * from schema_automator.generalizers import * + +try: + __version__ = metadata.version(__package__) +except metadata.PackageNotFoundError: + # package is not installed + __version__ = "0.0.0" # pragma: no cover diff --git a/schema_automator/cli.py b/schema_automator/cli.py index 92cbbef..dd25e01 100644 --- a/schema_automator/cli.py +++ b/schema_automator/cli.py @@ -33,6 +33,7 @@ from schema_automator.importers.sql_import_engine import SqlImportEngine from schema_automator.importers.tabular_import_engine import TableImportEngine from schema_automator.utils.schemautils import write_schema +from schema_automator import __version__ input_option = click.option( "-i", @@ -80,6 +81,7 @@ help="Set the level of verbosity") @click.option("-q", "--quiet", help="Silence all diagnostics") +@click.version_option(__version__, "-V", "--version") def main(verbose: int, quiet: bool): """Run the LinkML Schema Automator Command Line. From 07b9cfaac6ef2b536f07f107e188e9b8fe0c8d10 Mon Sep 17 00:00:00 2001 From: David Linke Date: Sat, 17 Aug 2024 15:30:22 +0200 Subject: [PATCH 2/2] Set same auto-versioning style as in LinkML --- pyproject.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 2892e94..5209ae5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -53,6 +53,8 @@ build-backend = "poetry_dynamic_versioning.backend" [tool.poetry-dynamic-versioning] enable = true +vcs = "git" +style = "pep440" [tool.poetry.scripts] schemauto = "schema_automator.cli:main"