Python setup.py和MANIFEST.in文件

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Python setup.py和MANIFEST.in文件相关的知识,希望对你有一定的参考价值。

Setup.py文件

from setuptools import setup
from codecs import open
 
# 第三方依赖包及版本号
requires = ['beautifulsoup4>=4.3.2',
           'gearman>=2.0.2',
           'pymongo>=2.7.2',
           'threadpool>=1.2.7',
           'geoip2>=2.1.0',
           'pywin32>=219']
 
# 包列表
packages = ['MSE',
           'MSE.Device',
           'MSE.Proxy',
           'MSE.Scanner',
           'MSE.Utility',
           'MSE.Worker',
           'MSE.Config']
 
with open('HISTORY.rst', 'r', 'utf-8') asf:
   history = f.read()
   
setup(
   name = 'MSE',
   version = '1.2.1',
   author = 'Edwin',
   author_email = '[email protected]',
   description = 'Industry device/system search engine',
   long_description = history,
   url = '-',
   packages = packages,
   include_package_data = True,
   entry_points = {'console_scripts': [
       'MSE-Manager = MSE.Worker.Manager:main',
   ]},
   package_dir = {'MSE': 'MSE'},
   install_requires = requires,
   license = 'Apache',
   #zip_safe = False,
   classifiers = [
       'Development Status :: 1 - Production/Stable',
       'Intended Audience :: Developers',
       'License :: OSI Approved :: Apache Software License',
       'Natural Language :: English',
       'Operating System :: OS Independent',
       'Programming Language :: Python',       
       'Programming Language :: Python :: 2.7',
       'Topic :: Software Development :: Libraries :: Python Modules',
   ],
)

 

MANIFEST.in文件

详细格式和參数參考https://docs.python.org/2/distutils/sourcedist.html

include HISTORY.rst
include MANIFEST.in
recursive-include MES/Utility *.mmdb

 

说明

1.      zip_safe = False 不压缩为一个egg文件,而是以文件夹的形式安装egg

2.      include_package_data = True。包括包数据

3.      MANIFEST.in文件,用于包括其它文件

4.      公布Manayer.py工具脚本:

entry_points ={‘console_scripts‘: [

‘MSE-Manager = MSE.Worker.Manager:main‘,

 ]},

安装后会在Python系统文件夹的Scripts文件夹下生成两个文件:MSE-Manager.exe和MSE-Manager.py

5.      打包命令:python setup.py sdist


本文地址:http://blog.csdn.net/fragmentalice/article/details/44833013




以上是关于Python setup.py和MANIFEST.in文件的主要内容,如果未能解决你的问题,请参考以下文章

设置python包

python打包

Python - 在 setup.py 安装之前和之后导入包模块

如何在没有 MANIFEST.in 文件的情况下包含 package_data?

python setup.py 安装和卸载 的正确姿势

在 CMake 中使用 setup.py 构建 python 包