summaryrefslogtreecommitdiff
path: root/setuptools/command/build_py.py
diff options
context:
space:
mode:
authorPJ Eby <distutils-sig@python.org>2005-11-18 17:29:47 +0000
committerPJ Eby <distutils-sig@python.org>2005-11-18 17:29:47 +0000
commite218cf0c77bcd66bfd5b9e30aee73f4787ed5b21 (patch)
tree938be63b396a54401f37cebb7c5e5c30514b2f22 /setuptools/command/build_py.py
parent82f063f0169698f55fd4234c47458ba50f3a2e30 (diff)
downloadpython-setuptools-git-e218cf0c77bcd66bfd5b9e30aee73f4787ed5b21.tar.gz
Added warning for namespace packages with missing ``declare_namespace()``,
updated docs for new policy/implementation, and explain the reasons for the change and what to do about it. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041479
Diffstat (limited to 'setuptools/command/build_py.py')
-rw-r--r--setuptools/command/build_py.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/setuptools/command/build_py.py b/setuptools/command/build_py.py
index fd09514f..35b9c57e 100644
--- a/setuptools/command/build_py.py
+++ b/setuptools/command/build_py.py
@@ -121,3 +121,44 @@ class build_py(_build_py):
+ def check_package(self, package, package_dir):
+ """Check namespace packages' __init__ for declare_namespace"""
+ try:
+ return self.packages_checked[package]
+ except KeyError:
+ pass
+
+ init_py = _build_py.check_package(self, package, package_dir)
+ self.packages_checked[package] = init_py
+
+ if not init_py or not self.distribution.namespace_packages:
+ return init_py
+
+ for pkg in self.distribution.namespace_packages:
+ if pkg==package or pkg.startswith(package+'.'):
+ break
+ else:
+ return init_py
+
+ f = open(init_py,'rU')
+ if 'declare_namespace' not in f.read():
+ from distutils import log
+ log.warn(
+ "WARNING: %s is a namespace package, but its __init__.py does\n"
+ "not declare_namespace(); setuptools 0.7 will REQUIRE this!\n"
+ '(See the setuptools manual under "Namespace Packages" for '
+ "details.)\n", package
+ )
+ f.close()
+ return init_py
+
+ def initialize_options(self):
+ self.packages_checked={}
+ _build_py.initialize_options(self)
+
+
+
+
+
+
+