The module was found in installation mode, but not in development mode using setuptools

I am using setuptools for the first time and am trying to pack my code so that others can easily develop it. I run everything in a virtual environment.

Short question . How to change the directory referenced by an egg when I run python setup.py develop ?

The long question . The module I'm developing is called cops_and_robots . When I run python setup.py install , everything works fine and I can import my cops_and_robots module. However, when I run python setup.py develop , import cops_and_robots because cops_and_robots.egg-link points to the wrong directory:

 (cops_and_robots)Antares:cops_and_robots nick$ cat ~/virtual_environments/cops_and_robots/lib/python2.7/site-packages/cops-and-robots.egg-link /Users/nick/Downloads/cops_and_robots/ . 

Here is the directory structure:

 |____Downloads | |____cops_and_robots # the whole package directory | | |____... | | |____requirements.txt | | |____setup.py | | |____src | | | |____cops_and_robots # the python package directory | | | |______init.py__ | | |____... 

And my setup.py :

 from setuptools import setup, find_packages import ez_setup ez_setup.use_setuptools() setup( # Author information and Metadata name='cops_and_robots', # Package data packages=find_packages('src'), package_dir={'cops_and_robots':'src/cops_and_robots'}, include_package_data=True, platforms='any', requires=['std_msgs','rospy'], tests_require=['pytest'], install_requires=[i.strip() for i in open("requirements.txt").readlines()], ) 

The manual fix is ​​to simply add src/cops_and_robots to the cops_and_robots.egg-link file, but I'm looking for a more elegant way to do this.

+5
source share
1 answer

It may be too late for your urgent need, but installing setuptools devel has encountered this problem for a long time. Fortunately, there is an easy workaround that might work in your case. Just try changing:

 # Package data packages=find_packages('src'), package_dir={'cops_and_robots':'src/cops_and_robots'}, 

to

 # Package data packages=find_packages('src'), package_dir={'':'src'}, 

in setup.py script.

This case should work quite well with setuptools setup.py devel and therefore with pip install -e .

For more information about this issue, see the following links:

+5
source

All Articles