{"action":"opened","issue":{"url":"https://api.github.com/repos/PyCQA/astroid/issues/337","repository_url":"https://api.github.com/repos/PyCQA/astroid","labels_url":"https://api.github.com/repos/PyCQA/astroid/issues/337/labels{/name}","comments_url":"https://api.github.com/repos/PyCQA/astroid/issues/337/comments","events_url":"https://api.github.com/repos/PyCQA/astroid/issues/337/events","html_url":"https://github.com/PyCQA/astroid/issues/337","id":154701962,"number":337,"title":"load_module_from_modpath does not fully support namespace packages","user":{"login":"NotSqrt","id":1997005,"avatar_url":"https://avatars.githubusercontent.com/u/1997005?v=3","gravatar_id":"","url":"https://api.github.com/users/NotSqrt","html_url":"https://github.com/NotSqrt","followers_url":"https://api.github.com/users/NotSqrt/followers","following_url":"https://api.github.com/users/NotSqrt/following{/other_user}","gists_url":"https://api.github.com/users/NotSqrt/gists{/gist_id}","starred_url":"https://api.github.com/users/NotSqrt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NotSqrt/subscriptions","organizations_url":"https://api.github.com/users/NotSqrt/orgs","repos_url":"https://api.github.com/users/NotSqrt/repos","events_url":"https://api.github.com/users/NotSqrt/events{/privacy}","received_events_url":"https://api.github.com/users/NotSqrt/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-05-13T12:36:38Z","updated_at":"2016-05-13T12:36:38Z","closed_at":null,"body":"Hi,\r\n\r\nI opened a ticket in pylint/issues#903 but it is probably in astroid itself:\r\nI have the following situation:\r\n\r\n```\r\n# package 1, installed with \"pip install package1\"\r\nmynamespace/\r\n    __init__.py\r\n    pylint_plugins/\r\n        __init__.py\r\n       plugin1.py\r\n\r\n# package 2, installed with \"pip install -e package2\"\r\nmynamespace/\r\n    __init__.py\r\n   # other modules\r\n```\r\n\r\nIn that situation, ``pylint --load-plugins mynamespace.pylint_plugins.plugin1`` fails, because ``load_module_from_modpath`` looks for ``pylint_plugins`` inside the folder of package2 installed in develop mode.\r\n\r\nCf what Django does to avoid this problem (it used to fail in some cases for django < 1.7): https://github.com/django/django/blob/1.9.6/django/utils/module_loading.py#L9\r\n\r\nSteps to reproduce easily:\r\n```bash\r\nmktmpenv \r\npip install pylint\r\nmkdir -p package1/mynamespace/pylint_plugins\r\nmkdir -p package2/mynamespace/\r\n# setup scripts\r\necho -e \"from setuptools import setup, find_packages\\nsetup(name='package1', version='0.1', packages=find_packages())\" > package1/setup.py\r\necho -e \"from setuptools import setup, find_packages\\nsetup(name='package2', version='0.1', packages=find_packages())\" > package2/setup.py\r\n# namespace declaration\r\necho -e \"from pkgutil import extend_path\\n__path__ = extend_path(__path__, __name__)\" > package1/mynamespace/__init__.py\r\necho -e \"from pkgutil import extend_path\\n__path__ = extend_path(__path__, __name__)\" > package2/mynamespace/__init__.py\r\n# other python files\r\ntouch package1/mynamespace/pylint_plugins/__init__.py\r\necho -e \"def register(linter):\\n    pass\" > package1/mynamespace/pylint_plugins/plugin1.py\r\n\r\npip install package1/\r\npip install -e package2/\r\npylint --load-plugins mynamespace.pylint_plugins.plugin1  \r\n# Fails because it looks for pylint_plugins in /absolute/path/to/package2/\r\n# Doing the installs in reverse order does not fix the error\r\n\r\n# both with -e\r\npip uninstall -y package1 package2\r\npip install -e package1/ -e package2/\r\npylint --load-plugins mynamespace.pylint_plugins.plugin1  # ok\r\n\r\n# both regular install\r\npip uninstall -y package1 package2\r\npip install package1/ package2/\r\npylint --load-plugins mynamespace.pylint_plugins.plugin1  # ok\r\n```\r\n\r\nHow to fix this ?\r\n\r\nSince python2.6 does not seem supported in tox, we might simply use importlib, no ?\r\n\r\nThanks !"}}