工具:setuptools
步骤:
- 编写setup.py
#-*- encoding: UTF-8 -*-
from setuptools import setup,find_packages
setup(
name = "ostree_assembly",
version = "0.1",
packages = find_packages(),
description = 'A web tool to build an ostree image.',
author = 'JokerMa',
author_email = 'mazhiguo@kylinos.com.cn',
url = 'www.kylinsec.com.cn',
include_package_data=True,
zip_safe=True,
install_requires = [
'amqp==1.4.9',
'anyjson==0.3.3',
'configparser==4.0.2',
'contextlib2==0.6.0.post1',
'Django==1.9.8',
'django-bootstrap3==7.0.1',
'importlib-metadata==2.0.0',
'kombu==3.0.35',
'paho-mqtt==1.5.1',
'pathlib2==2.3.5',
'scandir==1.10.0',
'six==1.15.0',
'vine==1.3.0',
'zipp==1.2.0',
],
# entry_points={
# 'console_scripts':[
# 'path = demo.get_path:fun'
# ]
# },
)
- 编写 MANIFEST.in
include *.txt
recursive-include examples *.txt *.py
prune examples/sample?/build
-
将 setup.py 与 MANIFEST.in 与 Django项目 放置于同一级目录
-
执行 python3 setup.py bdist_rpm (打包成rpm包,也可打包成其他格式,如:wheel包)
注:
setup.py中设置打包的基本信息, 其中 install_requires 总所列出的依赖,打包成pip可安装的格式时,pip会自动解析安装这些依赖包;
packages = find_packages() 会自动查找包含init.py 的目录,进行打包
MANIFEST.in 文件中的 include 和 recursive-include可以打包除.py文件之外格式的文件
网友评论