From: W. Trevor King Date: Sun, 30 Dec 2012 18:15:28 +0000 (-0500) Subject: swc-installation-test-2.py: Fix 'mercurial' version extraction X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=90b42a2b5a73cd9ec0a34f0c4d1788f69ecfa607;p=swc-workshop.git swc-installation-test-2.py: Fix 'mercurial' version extraction The Mercurial Python package stores its version in strange places. --- diff --git a/swc-installation-test-2.py b/swc-installation-test-2.py index e25712a..7e1f731 100755 --- a/swc-installation-test-2.py +++ b/swc-installation-test-2.py @@ -353,8 +353,6 @@ class PythonPackageDependency (Dependency): for package,name,long_name,minimum_version in [ - ('mercurial', None, 'Mercurial Python package', - CHECKER['hg'].minimum_version), ('nose', None, 'Nose Python package', CHECKER['nosetests'].minimum_version), ('sqlite3', 'sqlite3-python', 'SQLite Python package', @@ -379,6 +377,23 @@ for package,name,long_name,minimum_version in [ del package, name, long_name, minimum_version # cleanup namespace +class MercurialPythonPackage (PythonPackageDependency): + def _get_version(self): + try: # mercurial >= 1.2 + package = _importlib.import_module('mercurial.util') + except ImportError as e: # mercurial <= 1.1.2 + package = self._get_package('mercurial.version') + return package.get_version() + else: + return package.version() + + +CHECKER['mercurial'] = MercurialPythonPackage( + package='mercurial.util', name='mercurial', + long_name='Mercurial Python package', + minimum_version=CHECKER['hg'].minimum_version) + + class VirtualDependency (Dependency): def _check(self): return '{0} {1}'.format(