[cig-commits] r12997 - in cs/merlin/branches/v1: . merlin merlin.egg-info

leif at geodynamics.org leif at geodynamics.org
Mon Oct 6 16:55:37 PDT 2008


Author: leif
Date: 2008-10-06 16:55:37 -0700 (Mon, 06 Oct 2008)
New Revision: 12997

Modified:
   cs/merlin/branches/v1/merlin.egg-info/PKG-INFO
   cs/merlin/branches/v1/merlin/__init__.py
   cs/merlin/branches/v1/pkg_resources.py
   cs/merlin/branches/v1/setup.py
Log:
Fixed a bug found by Charles while running 'pyrexc' from the Enthought
Python Distribution (EPD):

AttributeError: 'module' object has no attribute 'declare_namespace'

The bug was introduced in r5243 (see also r5212).  I merged
'pkg_resources.py' with 'merlin/__init__.py', leaving 'pkg_resources'
as a forwarding dummy.  Little did I know, there is an import cycle in
the pkg_resources code: as distributions are "activated", they can
double back and call 'pkg_resources'.


Modified: cs/merlin/branches/v1/merlin/__init__.py
===================================================================
--- cs/merlin/branches/v1/merlin/__init__.py	2008-10-05 10:54:21 UTC (rev 12996)
+++ cs/merlin/branches/v1/merlin/__init__.py	2008-10-06 23:55:37 UTC (rev 12997)
@@ -2685,14 +2685,7 @@
 add_activation_listener = working_set.subscribe
 run_script = working_set.run_script
 run_main = run_script   # backward compatibility
-# Activate all distributions already on sys.path, and ensure that
-# all distributions added to the working set in the future (e.g. by
-# calling ``require()``) will get activated as well.
-add_activation_listener(lambda dist: dist.activate())
-working_set.entries=[]; map(working_set.add_entry,sys.path) # match order
 
-
-
 # Merlin extensions
 
 def loadObject(name):
@@ -2711,3 +2704,19 @@
     return obj
 
 
+# Before activating distributions, initialize 'pkg_resources' in a
+# funky way.  This breaks the pkg_resources/merlin import cycle:
+# during activation, a namespace package might call
+# pkg_resources.declare_namespace(); but if we got here via "import
+# pkg_resources", 'pkg_resources' is still empty.  Setuptools doesn't
+# have this problem, because the activation code is within
+# 'pkg_resources' itself.
+import pkg_resources as x
+for attr in pkg_resources:
+    setattr(x, attr, globals()[attr])
+
+# Activate all distributions already on sys.path, and ensure that
+# all distributions added to the working set in the future (e.g. by
+# calling ``require()``) will get activated as well.
+add_activation_listener(lambda dist: dist.activate())
+working_set.entries=[]; map(working_set.add_entry,sys.path) # match order

Modified: cs/merlin/branches/v1/merlin.egg-info/PKG-INFO
===================================================================
--- cs/merlin/branches/v1/merlin.egg-info/PKG-INFO	2008-10-05 10:54:21 UTC (rev 12996)
+++ cs/merlin/branches/v1/merlin.egg-info/PKG-INFO	2008-10-06 23:55:37 UTC (rev 12997)
@@ -1,6 +1,6 @@
 Metadata-Version: 1.0
 Name: merlin
-Version: 1.4
+Version: 1.5
 Summary: A custom version of Phillip J. Eby's setuptools.
 Home-page: http://www.geodynamics.org/cig/software/packages/cs/pythia/
 Author: Leif Strand

Modified: cs/merlin/branches/v1/pkg_resources.py
===================================================================
--- cs/merlin/branches/v1/pkg_resources.py	2008-10-05 10:54:21 UTC (rev 12996)
+++ cs/merlin/branches/v1/pkg_resources.py	2008-10-06 23:55:37 UTC (rev 12997)
@@ -1,6 +1,4 @@
 
-from merlin import *
-
+# This module is initialized by merlin/__init__.py in order to avoid
+# the pkg_resources/merlin import cycle.
 import merlin
-
-__all__ = merlin.pkg_resources

Modified: cs/merlin/branches/v1/setup.py
===================================================================
--- cs/merlin/branches/v1/setup.py	2008-10-05 10:54:21 UTC (rev 12996)
+++ cs/merlin/branches/v1/setup.py	2008-10-06 23:55:37 UTC (rev 12997)
@@ -19,7 +19,7 @@
 d = {}; execfile(convert_path('merlin/command/__init__.py'), d)
 SETUP_COMMANDS = d['__all__']
 
-VERSION = "1.4"
+VERSION = "1.5"
 from merlin import setup, find_packages
 import sys
 scripts = []



More information about the cig-commits mailing list