本文地址:http://blog.youkuaiyun.com/spch2008/article/details/9082585
制作与安装
这篇文章讲的很详细,没有必要啰嗦啦。http://www.cnblogs.com/itech/archive/2011/02/13/1953268.html
setup.cfg
- 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.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
setup.py
- from setuptools import setup
- setup(
- setup_requires=['d2to1>=0.2.10,<0.3'],
- d2to1=True
- )
创建目录文件spch2008/__init__.py
- def hello():
- print "info : Hello World!"
- if __name__ == "__main__":
- hello()
目录格式:
- root@nova-controller:/home/sun/egg# ls
- setup.cfg setup.py spch2008
制作egg并安装
- 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
运行
- root@nova-controller:~# python -c "from spch2008 import hello; hello()"
- info : Hello World!
注释
- setup(
- setup_requires=['d2to1>=0.2.10,<0.3'],
- d2to1=True
- )
d2to1=True表明需要使用d2to1库,d2to1用来解释setup.cfg文件中的内容。