From 07e0fc06658f50147d1314bec6ca88aa818dd157 Mon Sep 17 00:00:00 2001 From: Kwabena N Amponsah Date: Sun, 22 Sep 2024 17:20:58 +0000 Subject: [PATCH] #12 Print version during run --- cppwg/__init__.py | 11 ++--------- cppwg/__main__.py | 3 ++- cppwg/generators.py | 3 +++ cppwg/version.py | 5 +++++ 4 files changed, 12 insertions(+), 10 deletions(-) create mode 100644 cppwg/version.py diff --git a/cppwg/__init__.py b/cppwg/__init__.py index 986567b..802c215 100644 --- a/cppwg/__init__.py +++ b/cppwg/__init__.py @@ -13,21 +13,14 @@ Contains string templates for Python wrappers. utils Contains utility functions and constants. +version + Contains version information. writers Contains writers for creating Python wrappers and writing to file. - -Utilities ---------- -__version__ - cppwg version string """ -from importlib import metadata - from cppwg.generators import CppWrapperGenerator __all__ = [ "CppWrapperGenerator", ] - -__version__ = metadata.version("cppwg") diff --git a/cppwg/__main__.py b/cppwg/__main__.py index 332c93c..0d6e209 100644 --- a/cppwg/__main__.py +++ b/cppwg/__main__.py @@ -3,7 +3,8 @@ import argparse import logging -from cppwg import CppWrapperGenerator, __version__ +from cppwg import CppWrapperGenerator +from cppwg.version import __version__ def parse_args() -> argparse.Namespace: diff --git a/cppwg/generators.py b/cppwg/generators.py index d734780..3a1b421 100644 --- a/cppwg/generators.py +++ b/cppwg/generators.py @@ -19,6 +19,7 @@ CPPWG_DEFAULT_WRAPPER_DIR, CPPWG_HEADER_COLLECTION_FILENAME, ) +from cppwg.version import __version__ as cppwg_version from cppwg.writers.header_collection_writer import CppHeaderCollectionWriter from cppwg.writers.package_writer import CppPackageWrapperWriter @@ -58,6 +59,8 @@ def __init__( ): logger = logging.getLogger() + logger.info(f"cppwg version {cppwg_version}") + # Check that castxml_binary exists and is executable self.castxml_binary: str = "" diff --git a/cppwg/version.py b/cppwg/version.py new file mode 100644 index 0000000..ef4a8c9 --- /dev/null +++ b/cppwg/version.py @@ -0,0 +1,5 @@ +"""Version information.""" + +from importlib import metadata + +__version__ = metadata.version("cppwg")