Merge pull request #1861 from benoit-pierre/fix_empty_namespace_package_wheel_install
Fix empty namespace package wheel install
This commit is contained in:
commit
705d41e490
|
@ -0,0 +1 @@
|
|||
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={
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
"""Wheels support."""
|
||||
|
||||
from distutils.util import get_platform
|
||||
from distutils import log
|
||||
import email
|
||||
import itertools
|
||||
import os
|
||||
|
@ -162,11 +163,17 @@ class Wheel:
|
|||
extras_require=extras_require,
|
||||
),
|
||||
)
|
||||
write_requirements(
|
||||
setup_dist.get_command_obj('egg_info'),
|
||||
None,
|
||||
os.path.join(egg_info, 'requires.txt'),
|
||||
)
|
||||
# Temporarily disable info traces.
|
||||
log_threshold = log._global_log.threshold
|
||||
log.set_threshold(log.WARN)
|
||||
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
|
||||
def _move_data_entries(destination_eggdir, dist_data):
|
||||
|
@ -206,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)
|
||||
|
|
Loading…
Reference in New Issue