-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
712f7d3
commit e57edab
Showing
3 changed files
with
82 additions
and
85 deletions.
There are no files selected for viewing
18 changes: 15 additions & 3 deletions
18
.github/workflows/release.yml → .github/workflows/auto_depoly.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# 开发指引 | ||
|
||
------ | ||
|
||
## 项目打包 | ||
|
||
每次修改代码后,记得同步修改 [`setup.py`](setup.py) 下的版本号 `version='x.y.z'`。 | ||
|
||
``` | ||
# 构建用于发布到 PyPI 的压缩包 | ||
python setup.py sdist | ||
# 本地安装(测试用) | ||
pip install .\dist\${project_name}-?.?.?.tar.gz | ||
# 本地卸载 | ||
pip uninstall ${project_name} | ||
``` | ||
|
||
## 项目发布 | ||
|
||
首先需要在 [PyPI](https://pypi.org/) 上注册一个帐号,并在本地用户根目录下创建文件 `~/.pypirc`(用于发布时验证用户身份),其内容如下: | ||
|
||
``` | ||
[distutils] | ||
index-servers=pypi | ||
[pypi] | ||
repository = https://upload.pypi.org/legacy/ | ||
username = <username> | ||
password = <password> | ||
``` | ||
|
||
其次安装 twine 并上传项目: | ||
|
||
``` | ||
# 首次发布需安装 | ||
pip install twine | ||
# 发布项目, 若发布成功可在此查看 https://pypi.org/manage/projects/ | ||
twine upload dist/* | ||
``` | ||
|
||
发布到 [PyPI](https://pypi.org/) 的项目名称必须是全局唯一的,即若其他用户已使用该项目名称,则无法发布(报错:`The user 'xxx' isn't allowed to upload to project 'yyy'.`)。此时只能修改 [`setup.py`](setup.py) 下的项目名称 `name`。 | ||
|
||
|
||
> 本项目已集成了 Github Workflows,每次推送更新到 master 即可自动打包并发布到 PyPI | ||
|
||
## 关于测试 | ||
|
||
详见 [单元测试说明](tests) | ||
|
||
|
||
## 参考资料 | ||
|
||
- [python package 开发指引](https://packaging.python.org/#python-packaging-user-guide) | ||
- [python package 示例代码](https://github.com/pypa/sampleproject) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters