【发布时间】:2015-08-24 14:08:26
【问题描述】:
我是第一次使用setuptools,并尝试打包我的代码,以便其他人可以轻松开发它。我在虚拟环境中运行一切。
小问题:当我运行python setup.py develop 时,如何更改 egg-link 指向的目录?
长问题:我正在开发的模块称为cops_and_robots。当我运行python setup.py install 时,一切正常,我可以导入我的cops_and_robots 模块。但是,当我运行python setup.py develop 时,运行import cops_and_robots 失败,因为cops_and_robots.egg-link 指向错误的目录:
(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/
.
目录结构如下:
|____Downloads
| |____cops_and_robots # the whole package directory
| | |____...
| | |____requirements.txt
| | |____setup.py
| | |____src
| | | |____cops_and_robots # the python package directory
| | | |______init.py__
| | |____...
还有我的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()],
)
手动修复只是将src/cops_and_robots 附加到cops_and_robots.egg-link 文件,但我正在寻找一种更优雅的方式来做到这一点。
【问题讨论】:
标签: python setuptools setup.py egg