Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
setuptools
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
setuptools
Commits
b9df5fd4
Commit
b9df5fd4
authored
Nov 27, 2017
by
Benoit Pierre
Committed by
GitHub
Nov 27, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1215 from benoit-pierre/fix_wheels_namespace_packages
fix namespace packages handling of wheels
parents
b066b290
da1c78f3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
0 deletions
+56
-0
CHANGES.rst
CHANGES.rst
+6
-0
setuptools/tests/test_wheel.py
setuptools/tests/test_wheel.py
+32
-0
setuptools/wheel.py
setuptools/wheel.py
+18
-0
No files found.
CHANGES.rst
View file @
b9df5fd4
v38
.2.2
-------
*
#
1214
:
fix
handling
of
namespace
packages
when
installing
from
a
wheel
.
v38
.2.1
-------
...
...
setuptools/tests/test_wheel.py
View file @
b9df5fd4
...
...
@@ -412,6 +412,38 @@ WHEEL_INSTALL_TESTS = (
),
),
dict
(
id
=
'namespace_package'
,
file_defs
=
{
'foo'
:
{
'bar'
:
{
'__init__.py'
:
''
},
},
},
setup_kwargs
=
dict
(
namespace_packages
=
[
'foo'
],
packages
=
[
'foo.bar'
],
),
install_tree
=
DALS
(
'''
foo-1.0-py{py_version}.egg/
|-- foo-1.0-py{py_version}-nspkg.pth
|-- EGG-INFO/
| |-- DESCRIPTION.rst
| |-- PKG-INFO
| |-- RECORD
| |-- WHEEL
| |-- metadata.json
| |-- namespace_packages.txt
| |-- top_level.txt
|-- foo/
| |-- __init__.py
| |-- bar/
| | |-- __init__.py
'''
),
),
)
@
pytest
.
mark
.
parametrize
(
...
...
setuptools/wheel.py
View file @
b9df5fd4
...
...
@@ -20,6 +20,13 @@ WHEEL_NAME = re.compile(
)\
.whl$
""",
re.VERBOSE).match
NAMESPACE_PACKAGE_INIT = '''\
try:
__import__('pkg_resources').declare_namespace(__name__)
except ImportError:
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
'''
class Wheel(object):
...
...
@@ -124,3 +131,14 @@ class Wheel(object):
os.rmdir(subdir)
if os.path.exists(dist_data):
os.rmdir(dist_data)
# Fix namespace packages.
namespace_packages = os.path.join(egg_info, 'namespace_packages.txt')
if os.path.exists(namespace_packages):
with open(namespace_packages) as fp:
namespace_packages = fp.read().split()
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):
with open(mod_init, 'w') as fp:
fp.write(NAMESPACE_PACKAGE_INIT)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment