[cig-commits] r5312 - cs/merlin/branches/v1/merlin/archimedes
leif at geodynamics.org
leif at geodynamics.org
Thu Nov 16 20:26:11 PST 2006
Author: leif
Date: 2006-11-16 20:26:11 -0800 (Thu, 16 Nov 2006)
New Revision: 5312
Modified:
cs/merlin/branches/v1/merlin/archimedes/__init__.py
Log:
Really work-around that pesky preinstalled pythia.merlin...
for real this time! Also work-around VersionConflict exception
in the same fashion.
Modified: cs/merlin/branches/v1/merlin/archimedes/__init__.py
===================================================================
--- cs/merlin/branches/v1/merlin/archimedes/__init__.py 2006-11-17 04:03:13 UTC (rev 5311)
+++ cs/merlin/branches/v1/merlin/archimedes/__init__.py 2006-11-17 04:26:11 UTC (rev 5312)
@@ -39,26 +39,30 @@
to ``sys.stderr`` and raise SystemExit in an attempt to abort the
calling script.
"""
- try:
- import merlin
- merlin.setup # AttributeError => merlin is pythia's merlin
- except (ImportError, AttributeError):
+
+ def bootstrap():
egg = download_merlin(package_index, to_dir, download_delay)
sys.path.insert(0, egg)
import merlin; merlin.bootstrap_install_from = egg
+ def rebootstrap():
+ del sys.modules['merlin']
+ bootstrap()
+
try:
+ import merlin
merlin.require(reqSpec)
+ except ImportError:
+ bootstrap()
+ except AttributeError:
+ # 'merlin' is pythia's merlin
+ del merlin
+ rebootstrap()
+ except merlin.VersionConflict:
+ # 'merlin' is a merlin from a different branch
+ del merlin
+ rebootstrap()
- except merlin.VersionConflict, e:
- # XXX could we install in a subprocess here?
- print >>sys.stderr, (
- "The required version of merlin (v%s) is not available, and\n"
- "can't be installed while this script is running. Please install\n"
- " a more recent version first.\n\n(Currently using %r)"
- ) % (branch, e.args[0])
- sys.exit(2)
-
def download_merlin(package_index=default_url, to_dir=os.curdir, delay=15):
"""Download merlin from a specified location and return its filename
More information about the cig-commits
mailing list