Python中包如何发布?
【摘要】Python中包如何发布?1 myModule目录结构体如下: setup py __init__ py test py sub_A __init__ py a py sub_B __init__ py b py2 编
Python中包如何发布?
1.myModule目录结构体如下:
./
setup.py
__init__.py
test.py
sub_A/
__init__.py
a.py
sub_B/
__init__.py
b.py
2.编辑setup.py文件
py_modules需指明所需包含的py文件
from distutils.core import setup
setup(name = "Se7eN_HOU",version = "1.0",description = "Se7eN_HOU's module",author = "Se7eN_HOU",
py_modules = ["sub_A.a","sub_B.b"])
相关推荐:《Python视频教程》
3.构建模块
使用控制台在setup.py文件的同目录下执行python setup.py build
C:UsersSe7eN_HOUDesktopmyModule>python setup.py build
running build
running build_py
copying sub_Aa.py -> buildlibsub_A
copying sub_Bb.py -> buildlibsub_B
C:UsersSe7eN_HOUDesktopmyModule>
构建后目录结构:
./
setup.py
__init__.py
test.py
sub_A/
__init__.py
a.py
sub_B/
__init__.py
b.py
build/
lib/
sub_A/
__init__.py
a.py
sub_B/
__init__.py
b.py
4.生成发布压缩包
同目录下执行python setup.py sdist
C:UsersSe7eN_HOUDesktopmyModule>python setup.py sdist
running sdist
running check
warning: check: missing required meta-data: url
warning: check: missing meta-data: if 'author' supplied, 'author_email' must be supplied too
warning: sdist: manifest template 'MANIFEST.in' does not exist (using default file list)
warning: sdist: standard file not found: should have one of README, README.txt, README.rst
writing manifest file 'MANIFEST'
creating Se7eN_HOU-1.0
creating Se7eN_HOU-1.0sub_A
creating Se7eN_HOU-1.0sub_B
making hard links in Se7eN_HOU-1.0...
hard linking setup.py -> Se7eN_HOU-1.0
hard linking sub_A__init__.py -> Se7eN_HOU-1.0sub_A
hard linking sub_Aa.py -> Se7eN_HOU-1.0sub_A
hard linking sub_B__init__.py -> Se7eN_HOU-1.0sub_B
hard linking sub_Bb.py -> Se7eN_HOU-1.0sub_B
creating dist
Creating tar archive
removing 'Se7eN_HOU-1.0' (and everything under it)
C:UsersSe7eN_HOUDesktopmyModule>
打包后,生成最终发布压缩包Se7eN_HOU-1.0tar.gz,目录结构
./
setup.py
__init__.py
test.py
sub_A/
__init__.py
a.py
sub_B/
__init__.py
b.py
build/
lib/
sub_A/
__init__.py
a.py
sub_B/
__init__.py
b.py
MANIFEST
dist/
Se7eN_HOU-1.0.tar.gz
相关推荐:
Python中包如何嵌套
上一篇:python爬虫的工作步骤
下一篇:Python中包如何嵌套
就业培训申请领取
环球青藤
官方QQ群扫描上方二维码或点击一键加群,免费领取大礼包,加群暗号:青藤。 一键加群
最新文章
Python编程各地入口
环球青藤官方微信服务平台
刷题看课 APP下载
免费直播 一键购课
代报名等人工服务
Python编程热点排行