2

Consider the following minimal Python project with setuptools packaging and a "pyproject.toml" file (see setuptools Build System Support):

> tree myproject
myproject
|-- myproject
|   `-- __init__.py
|-- pyproject.toml
|-- setup.cfg
`-- setup.py

"setup.py" is only a minimal dummy file to enable support for editable installs, as described here:

from setuptools import setup

if __name__ == '__main__':
    setup()

When performing an editable install (pip install -e) to a virtualenv, everything works as expected:

> ls venv/lib/python3.9/site-packages | grep myproject
myproject.egg-link

> cat venv/lib/python3.9/site-packages/easy-install.pth 
/myproject

> python3
>>> import myproject
Hello world!

The same is true for a non-editable system-wide install:

> ls /usr/local/lib/python3.9/dist-packages | grep myproject
myproject
myproject-1.0.dist-info

> python3
>>> import myproject
Hello world!

For an editable system-wide install, however, pip succeeds but does not result in a usable module:

> ls /usr/local/lib/python3.9/dist-packages | grep myproject
(No output)

> python3
>>> import myproject
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'myproject'

I'm aware that there were some issues in the past with "pyproject.toml" and editable installs. However, these appear to be fixed since 2019.

I have a relatively recent Debian Bullseye system with pip 20.3.4 and setuptools 52.0.0.

There also is PEP 660, which has not been implemented by setuptools yet. However, the dummy "setup.py" file (see above) should work around that limitation.

F30
  • 1,036
  • 1
  • 10
  • 21

1 Answers1

0

This is a Debian-specific problem.

Having a "pyproject.toml" file (i.e. a PEP 518 package), enables build isolation by default. On Debian, that results in editable installs ending up in "/usr/lib/python3.9/site-packages" instead of "/usr/local/lib/python3.9/dist-packages":

> ls /usr/lib/python3.9/site-packages
easy-install.pth  myproject.egg-link

> cat /usr/lib/python3.9/site-packages/easy-install.pth 
/myproject

However, "/usr/lib/python3.9/site-packages" is not part of the default Debian Python module paths.

I reported this behavior as Debian bug #1004149. Until it has been fixed, one can work around it by using pip install --no-build-isolation -e.

F30
  • 1,036
  • 1
  • 10
  • 21