[Checkins] SVN: zopeframework/trunk/source/steeringgroup/decisions.rst Add a note about declarating namespace packages.

Martijn Faassen faassen at infrae.com
Wed Mar 11 10:31:27 EDT 2009


Log message for revision 97839:
  Add a note about declarating namespace packages.
  

Changed:
  U   zopeframework/trunk/source/steeringgroup/decisions.rst

-=-
Modified: zopeframework/trunk/source/steeringgroup/decisions.rst
===================================================================
--- zopeframework/trunk/source/steeringgroup/decisions.rst	2009-03-11 14:10:29 UTC (rev 97838)
+++ zopeframework/trunk/source/steeringgroup/decisions.rst	2009-03-11 14:31:27 UTC (rev 97839)
@@ -31,3 +31,21 @@
   Framework packages in order to make the dependency graph easier to
   reason about. We will do this on a case by case basis though.
   
+* In namespace package's ``__init__.py`` we have been using the following
+  boilerplate code::
+
+    try:
+        import pkg_resources
+        pkg_resources.declare_namespace(__name__)
+    except ImportError:
+        import pkgutil
+        __path__ = pkgutil.extend_path(__path__, __name__)
+
+  Since ``setuptools`` is a dependency of our packages anyway, we 
+  can instead do the following::
+
+      __import__('pkg_resources').declare_namespace(__name__)
+
+  Feel free to use that and also feel free to simplify existing
+  ``__init__.py`` modules. Just make sure ``setuptools`` is a declared
+  dependency of the package.



More information about the Checkins mailing list