本文地址:http://blog.csdn.net/spch2008/article/details/9082585
这篇文章讲的很详细,没有必要啰嗦啦。http://www.cnblogs.com/itech/archive/2011/02/13/1953268.html
setup( name = "spch2008", version="0.1.1", packages = find_packages(), zip_safe = False, description = "first egg", author = "sunpch", author_email = "sunpch@foxmail.com", license = "GPL", platforms = "Independant" )上述配置写在setup中过于庞大,如果继续添加参数,导致setup函数参数过于臃肿,此时,可以将配置参数写在配置文件中。
setup.cfg
[metadata] name = spch2008 version = 0.1.1 zip_safe = False description = first egg author = sunpch author-email = sunpch@foxmail.com license = GPL platforms = Independant [files] packages = spch2008
from setuptools import setup setup( setup_requires=['d2to1>=0.2.10,<0.3'], d2to1=True )
def hello(): print "info : Hello World!" if __name__ == "__main__": hello()
root@nova-controller:/home/sun/egg# ls setup.cfg setup.py spch2008
root@nova-controller:/home/sun/egg# python setup.py bdist_egg root@nova-controller:/home/sun/egg# ls build d2to1-0.2.10-py2.7.egg dist setup.cfg setup.py spch2008 spch2008.egg-info
安装
root@nova-controller:/home/sun/egg# python setup.py install creating /usr/local/lib/python2.7/dist-packages/spch2008-0.1.1-py2.7.egg Extracting spch2008-0.1.1-py2.7.egg to /usr/local/lib/python2.7/dist-packages由上可见,将egg信息拷贝到相应目录中。
运行
root@nova-controller:~# python -c "from spch2008 import hello; hello()" info : Hello World!
setup( setup_requires=['d2to1>=0.2.10,<0.3'], d2to1=True )为了安装本文制作的egg,需要安装d2to1(版本要大于等于0.2.10,但要小于0.3)。
d2to1=True表明需要使用d2to1库,d2to1用来解释setup.cfg文件中的内容。