Commit 16a3ef93 authored by Benoit Pierre's avatar Benoit Pierre

wheel: fix installation of empty namespace package

parent d7810a90
Fix empty namespace package installation from wheel.
......@@ -450,6 +450,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={
......
......@@ -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)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment