Modify

Opened 3 years ago

Last modified 3 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

     
    1414        'author': 'Jun Omae',
    1515        'author_email': 'jun66j5@gmail.com',
    1616        'packages': find_packages(exclude=['*.tests*']),
     17        'namespace_packages': ['tracext'],
    1718        'package_data': {
    1819            'tracext.pygit2': ['locale/*/LC_MESSAGES/*.mo'],
    1920        },
  • 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)

Change History (1)

comment:1 Changed 3 years ago by Ryan J Ollos

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The owner will remain Jun Omae.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.