这是项目的文件结构。
setuptools应该是对标准库中的setup模块进行了封装,看起来更好用一些。
打包过程
前提 安装setuptools模块,一般都会安装,因为pip的原因。
在project目录下,新建一个setup.py 文件。
#coding:utf-8
#package project
from setuptools import setup, find_packages
setup(
name="apmonitor",
version="1.0.0",
author="orangleliu",
author_email="orangleliu@gmail.com",
#自动寻找带有 __init__.py 的文件夹
packages=find_packages(exclude=["logs"]),
install_requires = ['django==1.6'],
description = "ap monitor system",
#单独的一些py脚本,不是在某些模块中
scripts = ["dbrouters.py","index.py",
"manage.py", "settings.py",
"uwsgi.py", "__ini__.py"],
#静态文件等,配合MANIFEST.in (package_data 参数不太好使)
include_package_data = True,
#如果是正式的项目,还会有更多的信息(例如开源证书写在下面)
url = "http://wifi21.com",
)
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
这里的文件只包含了python的一些脚本,还有打包信息
添加静态资源(htm 样式 js 图片 配置等)需要另外一个配置文件MANIFEST.in
recursive-include conf *
recursive-include staticfiles *
recursive-include templates *
recursive-include */templates *
然后再使用命令打包
python setup.py sdist
会在setup.py 同级的目录下生成一个dist文件夹,里面包含了打包好的文件,同时生成了一个xxx.egg-info 的文件。
小结
这个过程是最简单的,只有一些pyhton模块和静态资源的打包,setup还可以生成许多中格式的包,更多的定制选项,查文档可获得。后面需要一些定制的东西,有些变了生成,还有一些自动化的东西添加。
声明:
本文出自 “orangleliu笔记本” 博客,转载请务必保留此出处http://blog.csdn.net/orangleliu/article/details/46604237 作者orangleliu 采用署名-非商业性使用-相同方式共享协议
文章来源: blog.csdn.net,作者:轻狂书生FS,版权归原作者所有,如需转载,请联系作者。
原文链接:blog.csdn.net/LookForDream_/article/details/78625281
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
评论(0)