pip install -e doesn't allow to import via package dir
Solution 1:
In order to use a so-called src
-layout with setuptools the setup.py should look like this :
from setuptools import setup, find_packages
setup(
name='test-pkg',
packages=find_packages('src'),
package_dir={
'': 'src',
},
)
The package_dir
should get an empty string as key.
It is kind of explained in the "deprecated" documentation of setuptools:
The keys to this dictionary are package names, and an empty package name stands for the root package. The values are directory names relative to your distribution root. In this case, when you say
packages = ['foo']
, you are promising that the filelib/foo/__init__.py
exists.
-- https://setuptools.pypa.io/en/latest/deprecated/distutils/setupscript.html?highlight=package_dir#listing-whole-packages
...and kind of in the newest version of the documentation, but it is somewhat possible to piece things together:
- https://setuptools.pypa.io/en/latest/userguide/package_discovery.html#using-find-or-find-packages
- https://setuptools.pypa.io/en/latest/userguide/declarative_config.html#using-a-src-layout