How can I make pip / setuptools understand that my package is in. / Src?

I have a library with a layout similar to this on Github:

README setup.py src/ somelibrary.py 

Note. I cannot change the layout, but I can change the setup.py.

I want to be able to reference this library from a .txt requirement so that people can do pip install -r requirements.txt and install it automatically. Therefore, I add this line to the requirements:

 -e git+http://blablabla/blabla#egg=somelibrary 

This will clone the repository into. / src / somelibrary, and then run setup.py develop on it, which simply adds a link to. / src / somelibrary in site packages. Unfortunately, since the library is actually located at. / src / somelibrary / src , it looks like python cannot see the library correctly.

What am I missing? I assume this should be the setup.py parameter, which I am using incorrectly.

+4
source share
1 answer

You can simply put this in the setup function:

 package_dir = {'': 'src'}, 

This maps the base package directory to src.

+4
source

Source: https://habr.com/ru/post/1441071/


All Articles