Coverage for kwant/version.py : 51%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# Copyright 2011-2017 Kwant authors. # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at # http://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at # http://kwant-project.org/authors.
# This module must also work with Python 2.
# No public API
error = "This version of Kwant requires Python {} or above.".format( ".".join(str(p) for p in required_version)) if v[0] == 2: error += "\nKwant 1.1 is the last version to support Python 2." print(error, file=sys.stderr) sys.exit(1)
cwd=distr_root, stdout=subprocess.PIPE, stderr=subprocess.PIPE) except OSError: return return distr_root): # The top-level directory of the current Git repository is not the same # as the root directory of the Kwant distribution: do not extract the # version from Git. return
# git describe --first-parent does not take into account tags from branches # that were merged-in. cwd=distr_root, stdout=subprocess.PIPE, stderr=subprocess.PIPE) except OSError: return else: return
except OSError: labels.append('confused') # This should never happen. else: labels.append('dirty')
# TODO: change this logic when there is a git pretty-format # that gives the same output as 'git describe'. # Currently we can only tell the tag the current commit is # pointing to, or its hash (with no version info) # if it is not tagged. try: refnames = version_info['refnames'] git_hash = version_info['git_hash'] except KeyError: # These fields are not present if we are running from an sdist. # Execution should never reach here, though return None
if git_hash.startswith('$Format') or refnames.startswith('$Format'): # variables not expanded during 'git archive' return None
VTAG = 'tag: v' # Our version tags always start with 'v' refs = set(r.strip() for r in refnames.split(",")) version_tags = set(r[len(VTAG):] for r in refs if r.startswith(VTAG)) if version_tags: release, *_ = sorted(version_tags) # prefer e.g. "2.0" over "2.0rc1" return release else: return ''.join(('unknown', '+g', git_hash))
global version, version_is_from_git version = get_version_from_git_archive(version_info) version = "unknown"
|