aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--changelog.d/1861.change.rst1
-rw-r--r--setuptools/tests/test_wheel.py28
-rw-r--r--setuptools/wheel.py4
3 files changed, 32 insertions, 1 deletions
diff --git a/changelog.d/1861.change.rst b/changelog.d/1861.change.rst
new file mode 100644
index 00000000..5a4e0a56
--- /dev/null
+++ b/changelog.d/1861.change.rst
@@ -0,0 +1 @@
+Fix empty namespace package installation from wheel.
diff --git a/setuptools/tests/test_wheel.py b/setuptools/tests/test_wheel.py
index e85a4a7e..d50816c2 100644
--- a/setuptools/tests/test_wheel.py
+++ b/setuptools/tests/test_wheel.py
@@ -451,6 +451,34 @@ WHEEL_INSTALL_TESTS = (
),
dict(
+ id='empty_namespace_package',
+ file_defs={
+ 'foobar': {
+ '__init__.py': "__import__('pkg_resources').declare_namespace(__name__)",
+ },
+ },
+ setup_kwargs=dict(
+ namespace_packages=['foobar'],
+ packages=['foobar'],
+ ),
+ install_tree=flatten_tree({
+ 'foo-1.0-py{py_version}.egg': [
+ 'foo-1.0-py{py_version}-nspkg.pth',
+ {'EGG-INFO': [
+ 'PKG-INFO',
+ 'RECORD',
+ 'WHEEL',
+ 'namespace_packages.txt',
+ 'top_level.txt',
+ ]},
+ {'foobar': [
+ '__init__.py',
+ ]},
+ ]
+ }),
+ ),
+
+ dict(
id='data_in_package',
file_defs={
'foo': {
diff --git a/setuptools/wheel.py b/setuptools/wheel.py
index 2982926a..22eec05e 100644
--- a/setuptools/wheel.py
+++ b/setuptools/wheel.py
@@ -213,6 +213,8 @@ class Wheel:
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):
+ if not os.path.exists(mod_dir):
+ os.mkdir(mod_dir)
+ if not os.path.exists(mod_init):
with open(mod_init, 'w') as fp:
fp.write(NAMESPACE_PACKAGE_INIT)