diff options
author | Benoit Pierre <benoit.pierre@gmail.com> | 2018-09-17 23:40:12 +0200 |
---|---|---|
committer | Benoit Pierre <benoit.pierre@gmail.com> | 2019-10-07 23:05:15 +0200 |
commit | 16a3ef93fc66373f6c5f4da12303dd111403fcb1 (patch) | |
tree | 2dc23ae542e4b88f2bfe38e35188972fc0d70ce7 | |
parent | d7810a901382b827146874704f33bce896e1fb21 (diff) | |
download | external_python_setuptools-16a3ef93fc66373f6c5f4da12303dd111403fcb1.tar.gz external_python_setuptools-16a3ef93fc66373f6c5f4da12303dd111403fcb1.tar.bz2 external_python_setuptools-16a3ef93fc66373f6c5f4da12303dd111403fcb1.zip |
wheel: fix installation of empty namespace package
-rw-r--r-- | changelog.d/1861.change.rst | 1 | ||||
-rw-r--r-- | setuptools/tests/test_wheel.py | 28 | ||||
-rw-r--r-- | setuptools/wheel.py | 4 |
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) |