diff --git a/gecrooks_python_template/__init__.py b/gecrooks_python_template/__init__.py index de2adb4..9f04957 100644 --- a/gecrooks_python_template/__init__.py +++ b/gecrooks_python_template/__init__.py @@ -1,6 +1,6 @@ # Copyright 2019-2021, Gavin E. Crooks and contributors # -# This source code is licensed under the Apache License, Version 2.0 found in +# This source code is licensed under the Apache License 2.0 found in # the LICENSE.txt file in the root directory of this source tree. from .config import __version__ # noqa: F401 diff --git a/gecrooks_python_template/about.py b/gecrooks_python_template/about.py index 9ac4a9f..4dac1ea 100644 --- a/gecrooks_python_template/about.py +++ b/gecrooks_python_template/about.py @@ -1,6 +1,6 @@ # Copyright 2019-2021, Gavin E. Crooks and contributors # -# This source code is licensed under the Apache License, Version 2.0 found in +# This source code is licensed under the Apache License 2.0 found in # the LICENSE.txt file in the root directory of this source tree. # Command line interface for the about() function diff --git a/gecrooks_python_template/config.py b/gecrooks_python_template/config.py index f0624e9..e97c992 100644 --- a/gecrooks_python_template/config.py +++ b/gecrooks_python_template/config.py @@ -1,6 +1,6 @@ # Copyright 2019-2021, Gavin E. Crooks and contributors # -# This source code is licensed under the Apache License, Version 2.0 found in +# This source code is licensed under the Apache License 2.0 found in # the LICENSE.txt file in the root directory of this source tree. """ @@ -23,30 +23,33 @@ __all__ = ["__version__", "about"] -package_name = "gecrooks_python_template" - try: - __version__ = importlib_metadata.version(package_name) # type: ignore + __version__ = importlib_metadata.version(__package__) # type: ignore except Exception: # pragma: no cover # package is not installed __version__ = "?.?.?" def about(file: typing.TextIO = None) -> None: - f"""Print information about the configuration + f"""Print information about the package - ``> python -m {package_name}.about`` + ``> python -m {__package__}.about`` Args: file: Output stream (Defaults to stdout) """ + metadata = importlib_metadata.metadata(__package__) # type: ignore + print(f"# {metadata['Name']}", file=file) + print(f"{metadata['Summary']}", file=file) + print(f"{metadata['Home-page']}", file=file) + name_width = 24 versions = {} versions["platform"] = platform.platform(aliased=True) - versions[package_name] = __version__ + versions[__package__] = __version__ versions["python"] = sys.version[0:5] - for req in importlib_metadata.requires(package_name): # type: ignore + for req in importlib_metadata.requires(__package__): # type: ignore name = re.split("[; =><]", req)[0] try: versions[name] = importlib_metadata.version(name) # type: ignore @@ -54,7 +57,7 @@ def about(file: typing.TextIO = None) -> None: pass print(file=file) - print(f"# Configuration (> python -m {package_name}.about)", file=file) + print("# Configuration", file=file) for name, vers in versions.items(): print(name.ljust(name_width), vers, file=file) print(file=file) diff --git a/gecrooks_python_template/config_test.py b/gecrooks_python_template/config_test.py index b460e59..6edb30e 100644 --- a/gecrooks_python_template/config_test.py +++ b/gecrooks_python_template/config_test.py @@ -1,6 +1,6 @@ # Copyright 2019-2021, Gavin E. Crooks and contributors # -# This source code is licensed under the Apache License, Version 2.0 found in +# This source code is licensed under the Apache License 2.0 found in # the LICENSE.txt file in the root directory of this source tree. import glob