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)" 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/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 [] 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.',