python 打包工具
一、distutils (python 标准库)
- 安装
# 下载了源码发布文件foo-1.0.tar.gz # cd foo-1.0 # python setup.py install
- 创建执行文件 hello.py
def hello_fun(): print "hello word"
- 配置文件 setup.py
from distutils.core import setup setup( name="hello_module", version="1.0", author="ljk", author_email="wilber@sh.com", py_modules=['hello'], )
- 执行打包命令
python setup sdist
- 打包成功(当前目录下自动生成了一个文件夹dist,文件夹中有一个压缩包即为我们的目标文件,另有一个记录文件MANIFEST)
- 安装(hello_module-1.0.tar.gz 是生成的python模块)
sudo tar zvxf hello_module-1.0.tar.gz cd hello_module-1.0 python setup.py install
- 使用 (模块就是hello.py文件,引用hello.py文件中的hello_fun()函数)