python项目打包

一、python项目打包

python项目打包在项目的根目录下增加setup.py文件,基本格式如下

使用python setup.py install即可安装到本地

python3 setup.py bdist_wheel即可打包成.whl包

from setuptools import setup, find_packages

# python3 setup.py bdist_wheel
setup(name='data_sync',
      version='1.2.9',
      author=['wangbin', 'weiyuhua'],
      description='This is the basic toolkit package of the data platform',
      packages=find_packages(exclude=('cftool',)),
      install_requires=['pymongo', 'phoenixdb', 'pymysql', 'pyhive', 'boto3', 'pandas', 'requests', 'kafka'])

二、python项目依赖管理

requirements.txt文件用于记录项目用到的依赖包,pipreqs可以收集项目中用到的包到requirements.txt中

pip install pipreqs

pipreqs  ./ --encoding=utf8 --force
pip install -r requirements.txt
原文地址:https://www.cnblogs.com/wangbin2188/p/13967551.html