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/*