Skip to content

editable install makes separate submodules non-importable #11467

@dschwoerer

Description

@dschwoerer

Description

Installing a submodule into a package that has been installed with -e results in not importable submodule.

Expected behavior

Follow the .egg-link and install into that directory.

Alternatively error out if that is deemed not acceptable.

pip version

22.2.2

Python version

3.10

OS

Fedora 36

How to Reproduce

(I provide an example.tar.gz module + submodule for simple/fast testing ; ex1/ provides example1 and ex2/ provides example1/sub1)

pip install -e ex1/
pip install ex2/
python -c "import example1.sub1"

pip install ex1/ works around the issue and works as expected
An alternative fix is to manually link the submodule:
ln -s ../../ex2/example1/sub1/ ex1/example1/sub1

Output

$ tar -xf example.tar.gz
$ pip install -e ex1/
Defaulting to user installation because normal site-packages is not writeable
Obtaining file:///home/dave/tmp/test/ex1
  Preparing metadata (setup.py) ... done
Installing collected packages: example1
  Attempting uninstall: example1
    Found existing installation: example1 0.0.0
    Uninstalling example1-0.0.0:
      Successfully uninstalled example1-0.0.0
  Running setup.py develop for example1
Successfully installed example1-0.0.0
$ pip install ex2/
Defaulting to user installation because normal site-packages is not writeable
Processing ./ex2
  Preparing metadata (setup.py) ... done
Using legacy 'setup.py install' for example1.sub1, since package 'wheel' is not installed.
Installing collected packages: example1.sub1
  Attempting uninstall: example1.sub1
    Found existing installation: example1.sub1 0.0.0
    Uninstalling example1.sub1-0.0.0:
      Successfully uninstalled example1.sub1-0.0.0
  Running setup.py install for example1.sub1 ... done
Successfully installed example1.sub1-0.0.0
$ python -c "import example1.sub1"
Traceback (most recent call last):
  File "<string>", line 1, in <module>

ModuleNotFoundError: No module named 'example1.sub1'

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    S: needs triageIssues/PRs that need to be triagedtype: bugA confirmed bug or unintended behavior

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions