MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / get_versions

Function get_versions

monai/_version.py:614–657  ·  view source on GitHub ↗

Get version information or return default if unable to do so.

()

Source from the content-addressed store, hash-verified

612
613
614def get_versions():
615 """Get version information or return default if unable to do so."""
616 # I am in _version.py, which lives at ROOT/VERSIONFILE_SOURCE. If we have
617 # __file__, we can work backwards from there to the root. Some
618 # py2exe/bbfreeze/non-CPython implementations don't do __file__, in which
619 # case we can only use expanded keywords.
620
621 cfg = get_config()
622 verbose = cfg.verbose
623
624 try:
625 return git_versions_from_keywords(get_keywords(), cfg.tag_prefix,
626 verbose)
627 except NotThisMethod:
628 pass
629
630 try:
631 root = os.path.realpath(__file__)
632 # versionfile_source is the relative path from the top of the source
633 # tree (where the .git directory might live) to this file. Invert
634 # this to find the root from __file__.
635 for _ in cfg.versionfile_source.split('/'):
636 root = os.path.dirname(root)
637 except NameError:
638 return {"version": "0+unknown", "full-revisionid": None,
639 "dirty": None,
640 "error": "unable to find root of source tree",
641 "date": None}
642
643 try:
644 pieces = git_pieces_from_vcs(cfg.tag_prefix, root, verbose)
645 return render(pieces, cfg.style)
646 except NotThisMethod:
647 pass
648
649 try:
650 if cfg.parentdir_prefix:
651 return versions_from_parentdir(cfg.parentdir_prefix, root, verbose)
652 except NotThisMethod:
653 pass
654
655 return {"version": "0+unknown", "full-revisionid": None,
656 "dirty": None,
657 "error": "unable to compute version", "date": None}

Callers 2

_examine_monai_versionFunction · 0.90
__init__.pyFile · 0.70

Calls 7

get_configFunction · 0.85
get_keywordsFunction · 0.85
splitMethod · 0.80
git_pieces_from_vcsFunction · 0.70
renderFunction · 0.70
versions_from_parentdirFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…