aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/wheel.py
diff options
context:
space:
mode:
authorBenoit Pierre <benoit.pierre@gmail.com>2017-11-27 13:25:04 +0100
committerBenoit Pierre <benoit.pierre@gmail.com>2017-11-27 13:25:04 +0100
commitda1c78f354fac3ce177e2869828a34b3e6df1820 (patch)
treee3865ad7928e3274a743fd82159a2add0b70db4f /setuptools/wheel.py
parentb066b29042daf7b60c40d116f823ac28943cfbad (diff)
downloadexternal_python_setuptools-da1c78f354fac3ce177e2869828a34b3e6df1820.tar.gz
external_python_setuptools-da1c78f354fac3ce177e2869828a34b3e6df1820.tar.bz2
external_python_setuptools-da1c78f354fac3ce177e2869828a34b3e6df1820.zip
fix namespace packages handling of wheels
Diffstat (limited to 'setuptools/wheel.py')
-rw-r--r--setuptools/wheel.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/setuptools/wheel.py b/setuptools/wheel.py
index f711f38b..c2327213 100644
--- a/setuptools/wheel.py
+++ b/setuptools/wheel.py
@@ -20,6 +20,13 @@ WHEEL_NAME = re.compile(
)\.whl$""",
re.VERBOSE).match
+NAMESPACE_PACKAGE_INIT = '''\
+try:
+ __import__('pkg_resources').declare_namespace(__name__)
+except ImportError:
+ __path__ = __import__('pkgutil').extend_path(__path__, __name__)
+'''
+
class Wheel(object):
@@ -124,3 +131,14 @@ class Wheel(object):
os.rmdir(subdir)
if os.path.exists(dist_data):
os.rmdir(dist_data)
+ # Fix namespace packages.
+ namespace_packages = os.path.join(egg_info, 'namespace_packages.txt')
+ if os.path.exists(namespace_packages):
+ with open(namespace_packages) as fp:
+ namespace_packages = fp.read().split()
+ for mod in namespace_packages:
+ mod_dir = os.path.join(destination_eggdir, *mod.split('.'))
+ mod_init = os.path.join(mod_dir, '__init__.py')
+ if os.path.exists(mod_dir) and not os.path.exists(mod_init):
+ with open(mod_init, 'w') as fp:
+ fp.write(NAMESPACE_PACKAGE_INIT)