I'm using setuptools
for the first time, and trying to package my code so that others can easily develop it. I'm running everything in a virtual environment.
Short question: How do I change the directory that the egg-link points to when I run python setup.py develop
?
Long question: The module I'm developing is called cops_and_robots
. When I run python setup.py install
, things work fine and I'm able to import my cops_and_robots
module. However, when I run python setup.py develop
, running import cops_and_robots
fails because the 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's 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 just append src/cops_and_robots
to the cops_and_robots.egg-link
file, but I'm looking for a more elegant way to do that.
setuptools is a package development process library designed to facilitate packaging Python projects by enhancing the Python standard library distutils (distribution utilities). It includes: Python package and module definitions. Distribution package metadata.
A Python file that relies only on the standard library can be redistributed and reused without the need to use setuptools. But for projects that consist of multiple files, need additional libraries, or need a specific version of Python, setuptools will be required.
Usually, Yes. the setuptools is not part of the python vanilla codebase, hence not a vanilla modules. python.org installers or mac homebrew will install it for you, but if someone compile the python by himself or install it on some linux distribution he may not get it and will need to install it by himself.
Probably too late for your immediate need, but setuptools devel
installation has had this problem for a long time. Luckily, 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 your setup.py
script.
That case should work well enough with setuptools
setup.py devel
and thus with pip install -e
as well.
For some more background information on this issue, see the following links:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With