diff --git a/docs/source/conf.py b/docs/source/conf.py index 1c39e0b313..dbf738ee8a 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -117,7 +117,7 @@ def __getattr__(cls, name): # The default replacements for |version| and |release|, also used in various # other places throughout the built documents. # -version = str(pymor.VERSION) +version = pymor.__version__ # The full version, including alpha/beta/rc tags. release = version.split('-')[0] diff --git a/src/pymor/__init__.py b/src/pymor/__init__.py index cbe9d2a30a..4cd4640eed 100644 --- a/src/pymor/__init__.py +++ b/src/pymor/__init__.py @@ -15,62 +15,6 @@ from pymor.core.defaults import load_defaults_from_file -class Version(object): - def __init__(self, revstring): - - # special casing for debian versions like '0.1.3~precise~ppa9' - if '~' in revstring: - revstring = revstring[:revstring.index('~')] - revstringparts = revstring.strip().split('-') - if len(revstringparts) not in (1, 3): - raise ValueError('Invalid revstring: ' + revstring) - if len(revstringparts) == 3: - self.distance = int(revstringparts[1]) - self.shorthash = revstringparts[2] - else: - self.distance = 0 - self.shorthash = '' - - version_parts = revstringparts[0].split('.') - if version_parts[-1].find('rc') >= 0: - s = version_parts[-1].split('rc') - if len(s) != 2: - raise ValueError('Invalid revstring') - version_parts[-1] = s[0] - self.rc_number = int(s[1]) - self.has_rc_number = True - else: - self.rc_number = 0 - self.has_rc_number = False - - self.version = tuple(int(x) for x in version_parts) - self.full_version = self.version + (self.rc_number,) - - def __eq__(self, other): - if not isinstance(other, Version): - other = Version(other) - return self.version == other.version and self.rc_number == other.rc_number and self.distance == other.distance - - def __lt__(self, other): - if not isinstance(other, Version): - other = Version(other) - return self.full_version < other.full_version - - def __gt__(self, other): - if not isinstance(other, Version): - other = Version(other) - return self.full_version > other.full_version - - def __str__(self): - git_part = '-{}-{}'.format(self.distance, self.shorthash) if self.distance else '' - version_part = '.'.join(map(str, self.version)) - rc_part = 'rc{}'.format(self.rc_number) if self.has_rc_number else '' - return version_part + rc_part + git_part - - def __repr__(self): - return 'Version({})'.format(str(self)) - - if 'PYMOR_DEB_VERSION' in os.environ: revstring = os.environ['PYMOR_DEB_VERSION'] else: @@ -79,7 +23,6 @@ def __repr__(self): __version__ = str(revstring) - import os if 'PYMOR_DEFAULTS' in os.environ: filename = os.environ['PYMOR_DEFAULTS'] diff --git a/src/pymor/core/config.py b/src/pymor/core/config.py index 1ca9ff0072..a25b3c5f16 100644 --- a/src/pymor/core/config.py +++ b/src/pymor/core/config.py @@ -115,7 +115,7 @@ def __repr__(self): Defaults -------- See pymor.core.defaults.print_defaults. -'''[1:].format(self.version, self.PYTHON_VESRION, '-' * max(map(len, package_info)), +'''[1:].format(self.version, self.PYTHON_VERSION, '-' * max(map(len, package_info)), '\n'.join(package_info)) return info diff --git a/src/pymor/version.py b/src/pymor/version.py index 0fbb04347f..129bc726b5 100644 --- a/src/pymor/version.py +++ b/src/pymor/version.py @@ -474,7 +474,7 @@ def render(pieces, style): "date": pieces.get("date")} -def get_versions(version_default='0.0.0-0-0'): +def get_versions(): """Get version information or return default if unable to do so.""" # I am in _version.py, which lives at ROOT/VERSIONFILE_SOURCE. If we have # __file__, we can work backwards from there to the root. Some @@ -483,6 +483,7 @@ def get_versions(version_default='0.0.0-0-0'): cfg = get_config() verbose = cfg.verbose + version_default = '0.unknown' try: return git_versions_from_keywords(get_keywords(), cfg.tag_prefix, diff --git a/src/pymortests/core/interface.py b/src/pymortests/core/interface.py index 1e645796d6..6b3cfee295 100644 --- a/src/pymortests/core/interface.py +++ b/src/pymortests/core/interface.py @@ -55,8 +55,8 @@ def abstract_static_method(): assert inst.abstract_static_method() == 0 def testVersion(self): - assert pymor.VERSION > pymor.NO_VERSION - assert isinstance(pymor.VERSION, pymor.Version) + assert 'unknown' not in pymor.__version__ + assert '?' not in pymor.__version__ @SubclassForImplemetorsOf(ImmutableInterface)