[cig-commits] r5989 - cs/merlin/branches/v1/merlin

leif at geodynamics.org leif at geodynamics.org
Thu Feb 8 18:54:32 PST 2007


Author: leif
Date: 2007-02-08 18:54:32 -0800 (Thu, 08 Feb 2007)
New Revision: 5989

Modified:
   cs/merlin/branches/v1/merlin/sandbox.py
Log:
Inserted a hack so that Merlin can install 'NumPy' (a dependency of
PyLith/trunk).

The command "merlin install numpy" would work at first, but then crash
with an exception.  On the other hand, Setuptools ("easy_install
numpy") worked just fine.  Merlin is almost an exact copy of
Setuptools.  So what's going on?

Some digging revealed that NumPy has its own copy of distutils, which
was suspicious.  Then I spotted this hack in numpy.distutils.core:

    if 'setuptools' in sys.modules:
         have_setuptools = True
         #...

I have no idea why they didn't simply try/except around an 'import
setuptools' statement.  That would have worked under Merlin.  Instead,
NumPy peeked at 'sys.modules' and thus managed to escape from Merlin's
"setuptools jail".

One ugly hack deserves another, so now Merlin does

    import merlin
    sys.modules['setuptools'] = merlin

for the sole purpose of fooling NumPy.


Modified: cs/merlin/branches/v1/merlin/sandbox.py
===================================================================
--- cs/merlin/branches/v1/merlin/sandbox.py	2007-02-09 01:45:52 UTC (rev 5988)
+++ cs/merlin/branches/v1/merlin/sandbox.py	2007-02-09 02:54:32 UTC (rev 5989)
@@ -23,6 +23,10 @@
         try:
             sys.argv[:] = [setup_script]+list(args)
             sys.path.insert(0, setup_dir)
+            # Fool numpy.distutils.core.
+            import merlin
+            sys.modules['setuptools'] = merlin
+            # Fool everyone else.
             import merlin.jail as jail
             sys.path.insert(0, os.path.dirname(jail.__file__))
             DirectorySandbox(setup_dir).run(



More information about the cig-commits mailing list