Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version string #34

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
3 changes: 3 additions & 0 deletions jgo/__init__.py
Original file line number Diff line number Diff line change
@@ -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)
5 changes: 4 additions & 1 deletion jgo/jgo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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 []
Expand Down
24 changes: 24 additions & 0 deletions jgo/version_info.py
Original file line number Diff line number Diff line change
@@ -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()
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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='[email protected]',
description='Launch Java code from Python and the CLI, installation-free.',
Expand Down