From 2e1e8856907e3fc552b907a98fa78ac1136119af Mon Sep 17 00:00:00 2001 From: Philipp Hanslovsky Date: Wed, 16 Jan 2019 10:51:53 -0500 Subject: [PATCH 1/3] Manage version info in module --- jgo/__init__.py | 3 +++ jgo/version_info.py | 24 ++++++++++++++++++++++++ setup.py | 4 +++- 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 jgo/version_info.py diff --git a/jgo/__init__.py b/jgo/__init__.py index 62d933e..247e1e3 100644 --- a/jgo/__init__.py +++ b/jgo/__init__.py @@ -1,2 +1,5 @@ from .jgo import resolve_dependencies, jgo_main as main from .util import main_from_endpoint, maven_scijava_repository, add_jvm_args_as_necessary +from .version_info import _version as version + +__version__ = str(version) diff --git a/jgo/version_info.py b/jgo/version_info.py new file mode 100644 index 0000000..4f40beb --- /dev/null +++ b/jgo/version_info.py @@ -0,0 +1,24 @@ +_major = 0 +_minor = 4 +_patch = 1 +_extension = 'dev0' + +_version_string = '%d.%d.%d%s' % (_major, _minor, _patch, _extension) + +class Version(object): + def major(self): + return _major + + def minor(self): + return _minor + + def patch(self): + return _patch + + def extension(self): + return _extension + + def __str__(self): + return _version_string + +_version = Version() diff --git a/setup.py b/setup.py index cb10e67..8f0cc4c 100644 --- a/setup.py +++ b/setup.py @@ -6,9 +6,11 @@ with open(path.join(here, 'README.md')) as f: jgo_long_description = f.read() +from jgo import __version__ as version + setup( name='jgo', - version='0.4.1.dev0', + version=version, author='Philipp Hanslovsky, Curtis Rueden', author_email='hanslovskyp@janelia.hhmi.org', description='Launch Java code from Python and the CLI, installation-free.', From f3dceecca8537899ff4e7360900144bfd2294327 Mon Sep 17 00:00:00 2001 From: Philipp Hanslovsky Date: Wed, 16 Jan 2019 11:01:15 -0500 Subject: [PATCH 2/3] Add --version flag --- jgo/jgo.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/jgo/jgo.py b/jgo/jgo.py index 54cab66..7170eaa 100644 --- a/jgo/jgo.py +++ b/jgo/jgo.py @@ -11,6 +11,8 @@ import traceback import zipfile +from .version_info import _version as version + # A script to execute a main class of a Maven artifact # which is available locally or from Maven Central. # @@ -271,6 +273,7 @@ def jgo_parser(): parser.add_argument( '--additional-endpoints', nargs='+', help='Add additional endpoints', default=[], required=False) parser.add_argument('--ignore-jgorc', action='store_true', help='Ignore ~/.jgorc') parser.add_argument('--link-type', default=None, type=str, help='How to link from local maven repository into jgo cache. Defaults to the `links\' setting in ~/.jgorc or \'auto\' if not specified.', choices=('hard', 'soft', 'copy', 'auto')) + parser.add_argument('--version', action='version', version=str(version)) return parser @@ -514,7 +517,7 @@ def run(parser, argv=sys.argv[1:], stdout=None, stderr=None): endpoint_index = find_endpoint(argv, shortcuts) if endpoint_index == -1: - raise HelpRequested(argv) if '-h' in argv or '--help' in argv else NoEndpointProvided(argv) + raise HelpRequested(argv) if any(arg in argv for arg in ('--help', '-h', '--version')) else NoEndpointProvided(argv) args, unknown = parser.parse_known_args(argv[:endpoint_index]) jvm_args = unknown if unknown else [] From 39be8c6e4c451926e115061658984a90c40bff2d Mon Sep 17 00:00:00 2001 From: Philipp Hanslovsky Date: Wed, 16 Jan 2019 11:11:16 -0500 Subject: [PATCH 3/3] Test version in .travis/build.sh --- .travis/build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis/build.sh b/.travis/build.sh index 797c22f..c514e11 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -3,3 +3,4 @@ pip install . python -c 'import sys; sys.path.remove(""); import jgo' which jgo test "$(jgo org.scijava:parsington 1+3)" -eq 4 +test "$(python -c 'from jgo import __version__; print(__version__)')" = "$(jgo --version)"