cookiecutter-package
概述
Python第三方库模板
功能
- Cython: 编译Python程序,嵌入C语言等
- Sphinx + Read the Docs: 自动构建文档,挂载到
Read The Docs
- Travis-CI: 持续集成
- Pre-commit:预提交
- Tox:构建测试环境
- Bumpversion:多文件版本管理,自动commit,tag
- Pytest:测试
- Flake8: 代码检查
- Github/Gitee/Gitlab:选择代码托管平台
- Logging:集成日志配置
使用
$ pip3 install cookiecutter
$ cookiecutter https://github.com/caizhengxin/cookiecutter-package.git
project_name [My Awesome Project]: python-demo # 包名
project_slug [python_demo]: # 项目名,默认不用修改
description [Behold My Awesome Project!]: demo # 描述
author_name [JanKinCai]: # 作者名
email [[email protected]]: # 邮箱
version [0.1.0]: # 版本
Select code_hosting: # 选择代码托管平台,默认github
1 - github
2 - gitee
3 - gitlab
Choose from 1, 2, 3 (1, 2, 3) [1]:
code_hosting_username [JanKinCai]: # 托管平台用户名
Select open_source_license: # 选择开源license,默认MIT
1 - MIT
2 - BSD
3 - GPLv3
4 - Apache Software License 2.0
5 - Not open source
Choose from 1, 2, 3, 4, 5 (1, 2, 3, 4, 5) [1]: 2 # 选择BSD,根据自己选择合适的license
use_cython [n]: # 是否启用Cython,默认No
打包/发布
配置Pypi,
vim ~/.pypirc
[distutils]
index-server=pypi
[pypi]
username=你的账户
password=你的密码
$ pip3 install twine
$ python3 setup sdist
$ twine upload dist/*