Commit 705d41e4 authored by Benoit Pierre's avatar Benoit Pierre Committed by GitHub

Merge pull request #1861 from benoit-pierre/fix_empty_namespace_package_wheel_install

Fix empty namespace package wheel install
parents 5af71d2c 16a3ef93
Fix empty namespace package installation from wheel.
...@@ -450,6 +450,34 @@ WHEEL_INSTALL_TESTS = ( ...@@ -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( dict(
id='data_in_package', id='data_in_package',
file_defs={ file_defs={
......
"""Wheels support.""" """Wheels support."""
from distutils.util import get_platform from distutils.util import get_platform
from distutils import log
import email import email
import itertools import itertools
import os import os
...@@ -162,11 +163,17 @@ class Wheel: ...@@ -162,11 +163,17 @@ class Wheel:
extras_require=extras_require, extras_require=extras_require,
), ),
) )
write_requirements( # Temporarily disable info traces.
setup_dist.get_command_obj('egg_info'), log_threshold = log._global_log.threshold
None, log.set_threshold(log.WARN)
os.path.join(egg_info, 'requires.txt'), try:
) write_requirements(
setup_dist.get_command_obj('egg_info'),
None,
os.path.join(egg_info, 'requires.txt'),
)
finally:
log.set_threshold(log_threshold)
@staticmethod @staticmethod
def _move_data_entries(destination_eggdir, dist_data): def _move_data_entries(destination_eggdir, dist_data):
...@@ -206,6 +213,8 @@ class Wheel: ...@@ -206,6 +213,8 @@ class Wheel:
for mod in namespace_packages: for mod in namespace_packages:
mod_dir = os.path.join(destination_eggdir, *mod.split('.')) mod_dir = os.path.join(destination_eggdir, *mod.split('.'))
mod_init = os.path.join(mod_dir, '__init__.py') 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: with open(mod_init, 'w') as fp:
fp.write(NAMESPACE_PACKAGE_INIT) 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