Merge lp:~dobey/ubuntu/natty/logilab-common/namespace-packages into lp:ubuntu/natty/logilab-common
| Status: | Work in progress |
|---|---|
| Proposed branch: | lp:~dobey/ubuntu/natty/logilab-common/namespace-packages |
| Merge into: | lp:ubuntu/natty/logilab-common |
| Diff against target: |
77 lines (+59/-0) 3 files modified
debian/changelog (+8/-0) debian/patches/01_namespace_packages.patch (+49/-0) debian/patches/series (+2/-0) |
| To merge this branch: | bzr merge lp:~dobey/ubuntu/natty/logilab-common/namespace-packages |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Evan Broder (community) | Disapprove on 2010-12-16 | ||
| Ubuntu branches | 2010-12-15 | Pending | |
|
Review via email:
|
|||
| Sebastien Bacher (seb128) wrote : | # |
setting to work in progress so it's out of the sponsoring list until set back to "needs review"
| Natalia Bidart (nataliabidart) wrote : | # |
Hi,
Currently, I'm running
python-
When running pylint over a project that has several subprojects under the same namespace, such as ubuntuone, pylint doesn't find the imported modules that are located in the ubuntuone package but physically in a module in the PYTHONPATH but not in the current working directory.
What I said above, in an example, would be:
Package ubuntuone-client (installed in the system) provides ubuntuone.
ubuntuone/
__init__.py
clientdefs.py
Package ubuntuone-
The module ubuntuone.
nessita@dali:~$ python
Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ubuntuone.
>>>
But when running pylint over the ubuntuone.
nessita@
************* Module ubuntuone.
F0401: 27: Unable to import 'ubuntuone.
E0611: 27: No name 'clientdefs' in module 'ubuntuone'
F0401: 28: Unable to import 'ubuntuone.
E0611: 28: No name 'platform' in module 'ubuntuone'
F0401: 29: Unable to import 'ubuntuone.
E0611: 29: No name 'platform' in module 'ubuntuone'
nessita@
And all the required modules are available in the PYTHONPATH. We tried workarounding this by setting the PYTHONPATH is several ways, but pylint keeps failing. The patch proposed in the logilab ticket fixes this issue and as far as I can tell it is not a regression behavior but an enhancement.
Right now, pylint does not work in a certain amount of cases like this one. By applying the patch, we're making that amount a bit smaller.
I wrote to the logilab list a few weeks ago asking how to solve this issue and the only reply I got was:
"""
The pb is that pylint doesn't understand that yet... Nor direct __path__
manipulation.
"""
They suggested trying to workaroung the issue using the pylint's --init-hook swicth but that would not do the trick.
Is very common to have this division of the same namespace being provided by python packages (zope does that as well), so from my point of view it would be a huge gain to have pylint working correctly in those cases.
| Evan Broder (broder) wrote : | # |
Ok, I do appreciate the explanation. That was very helpful in understanding the issue.
That being said, it would still be *more* helpful in the future if the issue was explained in a bug report instead of a merge proposal history, which tends to be rather ephemeral. And equally importantly, it's helpful to reference that bug both in your changelog entry and in the patch you're adding (using http://
That's all important process stuff for once the patch is good. However, I still don't like this patch. In particular, I noticed that the new code your patch adds calls imp.find_
to search for a submodule of a package, pass the submodule name and the package's __path__.
The actual issue here is line 648 of modutils.py:
path = [mp_filename]
Imports of submodules are handled by looking at the __path__ attribute of the package module (This is sort of indirectly discussed in PEP-382 <http://
>>> import email
>>> email.__path__
['/usr/
So instead of setting path = [mp_filename] before going to the next loop iteration, you need to find the module itself (check out imp.load_module for doing that), grab its __path__ attribute, and set path to that. That's what the mailing list reply about direct __path__ manipulation is referring to.
Unmerged revisions
- 19. By dobey on 2010-12-20
-
Add DEP-3 information and series file
- 18. By dobey on 2010-12-15
-
* 01_namespace_
packages. patch: Work around for setuptools namespace packages
- Pulled from http://www.logilab. org/ticket/ 8796


I'm having a hard time understanding this patch. It would be helpful if there was a bug report that explained what you're trying to fix with a bit more detail.
That being said, as best as I *can* understand what's going on, this patch seems like it regresses behavior. The try/except block you introduce is completely included within the while loop you remove (with some extra code in the else block that you don't replicate).
Furthermore, the patch that you linked to appears to have been reported against 0.22.0 of logilab-astng. The version in Natty is *much* newer than that. 0.22.0 was released with Hardy 2 years ago. If you look at logilab- common/ modutils. py from back then (http:// bit.ly/ g2MP3x) the patch seems more like it would do something.