打包前:
]# ls -rlt
total 8
-rw-r--r--. 1 root root 325 Sep 11 08:57 setup.py
-rw-r--r--. 1 root root 95 Sep 11 08:57 setup.cfg
drwxr-xr-x. 2 root root 44 Sep 11 09:31 ouractions
]# ls ouractions/
__init__.py ouractions.py
说明: ouractions是一个python package。里面包含了一个python 脚本和__init__.py 文件
setup.py 内容:
from setuptools import setup, find_packages
setup(name='myactions',
version='0.3',
url='https://github.com/the-gigi/ouractions',
license='MIT',
py_modules=['ouractions/ouractions'],
author_email='[email protected]',
description='Manage configuration files',
zip_safe=False)
说明: py_modules 加上需要打进包里的py module.包的位置在
]# ls ouractions/
__init__.py ouractions.py
打包命令:(cd 到setup.py所在的目录)
python setup.py sdist
打包后的目录结构:在dist目录下生成了tar包,
]# ls -rlt
total 12
-rw-r--r--. 1 root root 325 Sep 11 08:57 setup.py
-rw-r--r--. 1 root root 95 Sep 11 08:57 setup.cfg
drwxr-xr-x. 2 root root 4096 Sep 11 08:58 myactions.egg-info
drwxr-xr-x. 2 root root 33 Sep 11 08:58 dist
drwxr-xr-x. 2 root root 44 Sep 11 09:31 ouractions
# ls dist/
myactions-0.3.tar.gz
安装到其他机器上:
tar zxvf myactions-0.3.tar.gz
cd myactions-0.3
python setup.py install