From 6ae03a95b773d91be5322a649284757017ae994a Mon Sep 17 00:00:00 2001 From: Klaus Reuter <klaus.reuter@mpcdf.mpg.de> Date: Fri, 1 Dec 2023 16:31:39 +0100 Subject: [PATCH] add option to print version information, fix URL, bump version to 0.1.8 --- condainer/condainer.py | 6 ++++-- condainer/main.py | 12 +++++++++--- condainer/version.py | 17 +++++++++++++++++ setup.py | 22 ++++++++++++++++------ 4 files changed, 46 insertions(+), 11 deletions(-) create mode 100644 condainer/version.py diff --git a/condainer/condainer.py b/condainer/condainer.py index caddda4..3ff61df 100644 --- a/condainer/condainer.py +++ b/condainer/condainer.py @@ -1,7 +1,9 @@ -"""Condainer -This file implements the functions to be called from main.py. +"""Condainer - condainer.py + +Entry point functions, and factorized building blocks implementing all functionality. """ + import os import sys import copy diff --git a/condainer/main.py b/condainer/main.py index 737b59c..8762286 100644 --- a/condainer/main.py +++ b/condainer/main.py @@ -1,10 +1,12 @@ -"""Condainer -Argument handling and calling of the functions implemented in condainer.py +"""Condainer - main.py + +Argument handling and calling of the entry points implemented in condainer.py """ import os import sys import argparse +from . import version from . import condainer def get_args(): @@ -13,7 +15,7 @@ def get_args(): parser = argparse.ArgumentParser( prog=sys.argv[0], description='Create and manage conda environments based on compressed squashfs images.', - epilog='More information at https://gitlab.mpcdf.mpg.de/khr/condainer' + epilog='More information at https://gitlab.mpcdf.mpg.de/mpcdf/condainer' ) parser.add_argument('-q', '--quiet', action='store_true', help='be quiet, do not write to stdout unless an error occurs') parser.add_argument('-d', '--directory', help='condainer project directory, the default is the current working directory') @@ -38,6 +40,8 @@ def get_args(): subparsers.add_parser('status', help='print status information about the condainer') # subparsers.add_parser('test', help=argparse.SUPPRESS) + subparsers.add_parser('version', help='print version information and exit') + args = parser.parse_args() return args @@ -65,3 +69,5 @@ def cli(): condainer.test(args) elif args.subcommand == 'status': condainer.status(args) + elif args.subcommand == 'version': + print(version.get_descriptive_version_string()) diff --git a/condainer/version.py b/condainer/version.py new file mode 100644 index 0000000..d877cb4 --- /dev/null +++ b/condainer/version.py @@ -0,0 +1,17 @@ +"""Condainer - version.py + +Single location for the version information. +""" + +ver = (0, 1, 8) + +def get_version_string(): + """Return the full version number.""" + return '.'.join(map(str, ver)) + +def get_short_version_string(): + """Return the version number without the patchlevel.""" + return '.'.join(map(str, ver[:-1])) + +def get_descriptive_version_string(): + return "Condainer " + get_version_string() \ No newline at end of file diff --git a/setup.py b/setup.py index 2002e22..642c2a5 100644 --- a/setup.py +++ b/setup.py @@ -1,17 +1,27 @@ -from setuptools import setup, find_packages from pathlib import Path +from setuptools import setup, find_packages + + +def get_long_description(): + base_dir = Path(__file__).parent + return (base_dir / "README.md").read_text() + -base_dir = Path(__file__).parent -long_description = (base_dir / "README.md").read_text() +def get_version_string(): + base_dir = Path(__file__).parent + version_py = (base_dir / "condainer" / "version.py").read_text() + ver = {} + exec(version_py, ver) + return ver['get_version_string']() setup( name='condainer', - version='0.1.8', + version=get_version_string(), description='Build, manage, and run compressed squashfs images of Conda environments transparently on HPC or elsewhere.', - long_description = long_description, + long_description = get_long_description(), author='Klaus Reuter', author_email='klaus.reuter@mpcdf.mpg.de', - url='https://gitlab.mpcdf.mpg.de/khr/condainer', + url='https://gitlab.mpcdf.mpg.de/mpcdf/condainer', packages=find_packages(include=['condainer',]), install_requires=[ 'PyYAML', -- GitLab