Modify ↓
Opened 7 years ago
Last modified 7 years ago
#13400 new defect
Missing package namespace declaration
Reported by: | Ryan J Ollos | Owned by: | Jun Omae |
---|---|---|---|
Priority: | normal | Component: | TracPygit2Plugin |
Severity: | normal | Keywords: | |
Cc: | Trac Release: |
Description
Is TracPygit2Plugin intended to be a namespace package?
I'm still trying to understand namespace packages. The packaging documentation says:
Every distribution that uses the namespace package must include an identical
__init__.py
. If any distribution does not, it will cause the namespace logic to fail and the other sub-packages will not be importable. Any additional code in__init__.py
will be inaccessible.
Here is the layout for TracMercurial:
$ cat tracext/__init__.py __import__('pkg_resources').declare_namespace(__name__) $ python setup.py bdist_wheel [...] $ pip install dist/TracMercurial-0.12.0.31.dev0-py2-none-any.whl [...] $ find pve/lib/python2.7/site-packages/tracext/ -name "*.py" pve/lib/python2.7/site-packages/tracext/hg/hooks.py pve/lib/python2.7/site-packages/tracext/hg/backend.py pve/lib/python2.7/site-packages/tracext/hg/__init__.py
Note there is no __init__.py
in pve/lib/python2.7/site-packages/tracext
.
TracPygit2Plugin yields:
$ cat tracext/__init__.py $ python setup.py bdist_wheel [...] $ pip install dist/TracPygit2Plugin-0.12.0.1-py2-none-any.whl [...] $ find pve/lib/python2.7/site-packages/tracext/ -name "*.py" $ pve/lib/python2.7/site-packages/tracext/pygit2/pygit2_fs.py $ pve/lib/python2.7/site-packages/tracext/pygit2/__init__.py $ pve/lib/python2.7/site-packages/tracext/pygit2/translation.py $ pve/lib/python2.7/site-packages/tracext/__init__.py $ pve/lib/python2.7/site-packages/tracext/hg/hooks.py $ pve/lib/python2.7/site-packages/tracext/hg/backend.py $ pve/lib/python2.7/site-packages/tracext/hg/__init__.py
With patch, now there is again no __init__.py
in pve/lib/python2.7/site-packages/tracext
.
-
setup.py
14 14 'author': 'Jun Omae', 15 15 'author_email': 'jun66j5@gmail.com', 16 16 'packages': find_packages(exclude=['*.tests*']), 17 'namespace_packages': ['tracext'], 17 18 'package_data': { 18 19 'tracext.pygit2': ['locale/*/LC_MESSAGES/*.mo'], 19 20 }, -
tracext/__init__.py
1 __import__('pkg_resources').declare_namespace(__name__)
$ python setup.py bdist_wheel [...] $ pip install dist/TracPygit2Plugin-0.12.0.1-py2-none-any.whl [...] $ find pve/lib/python2.7/site-packages/tracext/ -name "*.py" pve/lib/python2.7/site-packages/tracext/pygit2/pygit2_fs.py pve/lib/python2.7/site-packages/tracext/pygit2/__init__.py pve/lib/python2.7/site-packages/tracext/pygit2/translation.py pve/lib/python2.7/site-packages/tracext/hg/hooks.py pve/lib/python2.7/site-packages/tracext/hg/backend.py pve/lib/python2.7/site-packages/tracext/hg/__init__.py
Attachments (0)
Note: See
TracTickets for help on using
tickets.
See also: trac-github issue 131.