pip install --editable does not work as expected for namespace packages
See original GitHub issueEnvironment
- pip version: pip 19.3.1
- Python version: Python 3.6.8
- OS: linux
Description This is not a duplicate of #3
I have a mainpackage
that is a standard package with an __init__.py
. It has a subpackage, mainpackage.ext
, that is a namespace package according to PEP 420 (no __init__.py
).
All of this is located in a main_package
folder with a setup.py
.
Now I have a separate folder some_plugin
with another setup.py
. This folder contains a plugin for mainpackage
. It therefore has a package mainpackage.ext.someplugin
with an __init__.py
in mainpackage/ext/someplugin/
but not in mainpackage/
or mainpackage/ext/
.
Using a normal pip install
, this works as expected. But when using pip install -e
to install both main_package
and some_plugin
, the plugin cannot actually be imported.
Expected behavior
Same behavior between pip install
and pip install -e
, i.e. the ability to import mainpackage.ext.someplugin
without a ModuleNotFoundError
.
How to Reproduce I’ve created a repository with a minimal example: https://github.com/jonasrauber/python_namespace_packages_editable_bug
Works
sudo pip3 install main_package/
sudo pip3 install some_plugin/
python3 -c "import mainpackage; print(mainpackage.a)"
# -> hello
python3 -c "import mainpackage.ext.someplugin; print(mainpackage.ext.someplugin.a)"
# -> plugin
Fails
sudo pip3 install -e main_package/
sudo pip3 install -e some_plugin/
python3 -c "import mainpackage; print(mainpackage.a)"
# -> hello
python3 -c "import mainpackage.ext.someplugin; print(mainpackage.ext.someplugin.a)"
# -> ERROR
# Traceback (most recent call last):
# File "<string>", line 1, in <module>
# ModuleNotFoundError: No module named 'mainpackage.ext.someplugin'
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Top GitHub Comments
Does the same behaviour happen if you use
python setup.py develop
rather thanpip install -e
? The editable install mechanism is implemented by setuptools, so I suspect this may be down to how setuptools handles PEP 420 namespace packages. Checkingsetup.py develop
will help confirm this.This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don’t have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.