File tree Expand file tree Collapse file tree 2 files changed +69
-0
lines changed
Expand file tree Collapse file tree 2 files changed +69
-0
lines changed Original file line number Diff line number Diff line change 1+ # 工程笔记
2+
3+ ## 目录
4+
5+ ### Python
6+
7+ [ 打包并发布包到 PyPI] ( python/build-and-publish-package-to-pypi.md )
Original file line number Diff line number Diff line change 1+ # 打包并发布包到 PyPI
2+
3+ ## 安装依赖
4+
5+ ``` bash
6+ pip3 install setuptools
7+ pip3 install wheel
8+ pip3 install twine
9+ ```
10+
11+ ## 项目结构
12+
13+ setup.py
14+
15+ ``` python
16+ from setuptools import setup
17+
18+ setup(
19+ name = ' pytest_assume' ,
20+ version = ' 1.0.0' ,
21+ description = ' A print test for PyPI' ,
22+ author = ' winsrh' ,
23+ 24+ url = ' https://www.python.org/' ,
25+ license = ' MIT' ,
26+ keywords = ' ga nn' ,
27+ project_urls = {
28+ ' Documentation' : ' https://packaging.python.org/tutorials/distributing-packages/' ,
29+ ' Funding' : ' https://donate.pypi.org' ,
30+ ' Source' : ' https://github.com/pypa/sampleproject/' ,
31+ ' Tracker' : ' https://github.com/pypa/sampleproject/issues' ,
32+ },
33+ packages = [' pytest_assume' ], # 包名
34+ python_requires = ' >=3'
35+ )
36+ ```
37+
38+ ## 项目打包
39+
40+ 1 . 打包 tar.gz 源码包
41+
42+ ``` bash
43+ python setup.py sdist
44+ ```
45+
46+ 2 . 打包 whl 包
47+
48+ ``` bash
49+ python setup.py bdist_wheel
50+ ```
51+
52+ ## 取包地址
53+
54+ > /<项目目录>/dist/pytest_assume-1.0.0-py3-none-any.whl
55+ >
56+ > /<项目目录>/dist/pytest_assume-1.0.0.tar.gz
57+
58+ ## 发布到仓库
59+
60+ ``` bash
61+ twine upload dist/*
62+ ```
You can’t perform that action at this time.
0 commit comments