python/deploy_to_pypi
2# Deploy a new version of a Python library:
6# 3. Push to PyPI and GitHub.
8# This probably works for other projects as well, but relies on certain
9# aspects of the way the repos are laid out that may not be universal.
11# Note: unlike most Python scripts in this repo, this should run in
12# the project virtualenv rather than the script virtualenv.
20print_info
'-> rm -rfv dist/*'
25print_info
"-> uv build"
30print_info
"-> uv publish --username=__token__ --password=\$(…)"
31uv publish --username
=__token__ --password
=$(security find-generic-password -s
'https://upload.pypi.org/legacy/' -a __token__ -w
)
35version=$(grep -rl
'^__version__ = ' . --exclude-dir
=.venv
\
36 | xargs grep
'__version__ =' \
40print_info
"-> git tag v$version"
45print_info
"-> git push origin main --tag"
46git push origin main --tag