[BUG] package_dir in setuptools.setup() does not work as expected when installing with editable option
See original GitHub issuesetuptools version
56.0.0
Python version
Python 3.8.5
OS
Ubuntu 18.04.4 LTS (Bionic Beaver)
Additional environment information
No response
Description
Hello,
I followed the instructions in https://github.com/pypa/setuptools/blob/main/docs/deprecated/distutils/setupscript.rst#listing-whole-packages by using
setuptools.setup(
...
package_dir={'awesome_pkg': 'my_awesome_package'}
package=['awesome_pkg']
)
in order to package my_awesome_package
and later use it import awesome_pkg
after install.
But this unfortunately didn’t work.
Later I found out the reason is because I’ve installed the package with editable pip install -e .
option. It’s working without the -e
. I was unable to find any documentation on this and I would consider it as a hidden bug / discrepancy of the API (please correct me if I’m wrong).
I have the following path structure:
setup.py
my_awesome_pkg/
__init__.py
module_1/
__init__.py
...
module_2/
__init__.py
...
Expected behavior
import awesome_pkg
should work with the package installed by pip install -e
option
How to Reproduce
Please refer to bug report.
Output
<ipython-input-1-25a6a57694c2> in <module>
----> 1 import awesome_package
ModuleNotFoundError: No module named 'awesome_package'
Code of Conduct
- I agree to follow the PSF Code of Conduct
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:6 (2 by maintainers)
Top GitHub Comments
Related: https://stackoverflow.com/questions/64838393/package-dir-in-setup-py-not-working-as-expected
I cannot reproduce this, can you give a more complete reproducer?
Here’s my
setup.py
:Here’s how I created the directory structure:
If I do
pip install .
and thencd $(mktemp -d)
(so that I’m not in a directory containingmy_awesome_pkg
), thenpython -c "import awesome_pkg"
andpython -c "import my_awesome_pkg"
both fail.If I run
pip install -e .
thencd $(mktemp -d)
, I am able to importmy_awesome_pkg
but notawesome_pkg
, which is understandable considering thatsetup.py develop
is a monstrous hack and should probably not be counted on to have any particular semantics, but that seems to be the opposite of the behavior you are describing.