From f33f8eae61625763b44fc80744e2ae3d0900735f Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Tue, 31 May 2022 08:44:38 -0500 Subject: [PATCH 1/2] Adding version option to the plotter entry point --- openmc_plotter/__init__.py | 2 ++ openmc_plotter/__main__.py | 4 ++++ setup.py | 7 ++++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/openmc_plotter/__init__.py b/openmc_plotter/__init__.py index e69de29..cd57cb1 100644 --- a/openmc_plotter/__init__.py +++ b/openmc_plotter/__init__.py @@ -0,0 +1,2 @@ + +__version__ = '0.2.0' diff --git a/openmc_plotter/__main__.py b/openmc_plotter/__main__.py index 1230416..5acfdcd 100644 --- a/openmc_plotter/__main__.py +++ b/openmc_plotter/__main__.py @@ -10,10 +10,14 @@ from PySide2 import QtCore, QtGui from PySide2.QtWidgets import QApplication, QSplashScreen +from . import __version__ from .main_window import MainWindow, _openmcReload def main(): ap = ArgumentParser(description='OpenMC Plotter GUI') + version_str = f'OpenMC Plotter Version: {__version__}' + ap.add_argument('-v', '--version', action='version', version=version_str, + help='Display version info') ap.add_argument('-d', '--model-directory', default=os.curdir, help='Location of model dir (default is current dir)') ap.add_argument('-e','--ignore-settings', action='store_false', diff --git a/setup.py b/setup.py index e1effdf..788a1b5 100644 --- a/setup.py +++ b/setup.py @@ -1,8 +1,13 @@ from setuptools import setup +# Get version information from __init__.py. This is ugly, but more reliable than +# using an import. +with open('openmc_plotter/__init__.py', 'r') as f: + version = f.readlines()[-1].split()[-1].strip("'") + kwargs = { 'name': 'openmc-plotter', - 'version': '0.2.0', + 'version': version, 'packages': ['openmc_plotter'], 'package_data': {'openmc_plotter' : ['assets/*.png']}, 'entry_points': { From 85d2f30f08a5b6163739d54b204bcbd32e42a557 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Tue, 31 May 2022 08:46:25 -0500 Subject: [PATCH 2/2] Punctuation --- openmc_plotter/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openmc_plotter/__main__.py b/openmc_plotter/__main__.py index 5acfdcd..ee8caec 100644 --- a/openmc_plotter/__main__.py +++ b/openmc_plotter/__main__.py @@ -17,7 +17,7 @@ def main(): ap = ArgumentParser(description='OpenMC Plotter GUI') version_str = f'OpenMC Plotter Version: {__version__}' ap.add_argument('-v', '--version', action='version', version=version_str, - help='Display version info') + help='Display version info.') ap.add_argument('-d', '--model-directory', default=os.curdir, help='Location of model dir (default is current dir)') ap.add_argument('-e','--ignore-settings', action='store_false',