File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# Publishing to PyPI
22
3- https://packaging.python.org/en/latest/tutorials/packaging-projects/
3+ Package: https://pypi.org/project/pgsql-test/
4+ Reference: https://packaging.python.org/en/latest/tutorials/packaging-projects/
5+
6+ The build backend is ` poetry-core ` (see ` pyproject.toml ` ), but you do not need
7+ Poetry installed to release. The standard ` build ` + ` twine ` tools work.
8+
9+ ## One-time setup
10+
11+ ``` bash
12+ python3 -m pip install --upgrade build twine
13+ ```
14+
15+ Create a PyPI API token at https://pypi.org/manage/account/#api-tokens and put it
16+ in ` ~/.pypirc ` :
17+
18+ ``` ini
19+ [pypi]
20+ username = __token__
21+ password = pypi-...
22+ ```
23+
24+ ## Release
25+
26+ 1 . Bump ` version ` in ` pyproject.toml ` (PyPI will reject a re-upload of an existing version).
27+ 2 . Make sure CI is green on ` main ` .
28+ 3 . Build and check:
29+
30+ ``` bash
31+ rm -rf dist
32+ python3 -m build
33+ twine check dist/*
34+ ```
35+
36+ 4 . Upload:
37+
38+ ``` bash
39+ twine upload dist/*
40+ ```
41+
42+ 5 . Tag and push:
43+
44+ ``` bash
45+ git tag v$( python3 -c " import tomllib;print(tomllib.load(open('pyproject.toml','rb'))['tool']['poetry']['version'])" )
46+ git push --tags
47+ ```
48+
49+ To do a dry run against TestPyPI first, add a ` [testpypi] ` section to ` ~/.pypirc `
50+ with a token from https://test.pypi.org and run
51+ ` twine upload --repository testpypi dist/* ` .
You can’t perform that action at this time.
0 commit comments