From 6107d16c11494c328e8dfeb50fbb72ae5c7a3ecb Mon Sep 17 00:00:00 2001 From: Dave Chen Date: Wed, 28 Feb 2024 17:18:08 -0500 Subject: [PATCH] Added version var; fixed script main call --- dicom2stl/__init__.py~ | 7 ------- dicom2stl/utils/parseargs.py | 13 +++++++++++++ pyproject.toml | 4 ++-- 3 files changed, 15 insertions(+), 9 deletions(-) delete mode 100644 dicom2stl/__init__.py~ diff --git a/dicom2stl/__init__.py~ b/dicom2stl/__init__.py~ deleted file mode 100644 index 3e5740f..0000000 --- a/dicom2stl/__init__.py~ +++ /dev/null @@ -1,7 +0,0 @@ -import dicom2stl.utils.parseargs -import dicom2stl.dicom2stl_func -def main(): - """Entry point for the application script""" - print("Call your main application code here") - args = parseargs.parseargs() - dicom2stl_func.dicom2stl_func(args) diff --git a/dicom2stl/utils/parseargs.py b/dicom2stl/utils/parseargs.py index 737ea63..f25b4c4 100644 --- a/dicom2stl/utils/parseargs.py +++ b/dicom2stl/utils/parseargs.py @@ -2,6 +2,16 @@ import argparse +from importlib.metadata import version, PackageNotFoundError + +__version__ = "unknown" + +try: + __version__ = version("dicom2stl") +except PackageNotFoundError: + # package is not installed + pass + class disableFilter(argparse.Action): def __call__(self, parser, args, values, option_string=None): @@ -104,6 +114,9 @@ def createParser(): help="Dicom series search string", ) + parser.add_argument("--version", action="version", version=f"{__version__}") + + # Options that apply to the volumetric portion of the pipeline vol_group = parser.add_argument_group("Volume options") diff --git a/pyproject.toml b/pyproject.toml index 2df769f..b16559c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,10 +25,10 @@ dynamic = ["dependencies", "version"] dependencies = {file = ["requirements.txt"]} [tool.setuptools.packages.find] -exclude = ["docs*", "tests*", "binder*", "utils*", "examples*"] +exclude = ["docs*", "tests*", "binder*", "utils*", "examples*", "tmp*"] [project.scripts] -dicom2stl = "Dicom2STL:main" +dicom2stl = "dicom2stl.Dicom2STL:main" [tool.setuptools_scm] local_scheme = "dirty-tag"