cibuildwheel-autopypi-example
cibuildwheel-autopypi-example copied to clipboard
Example repo showing how to build wheels with cibuildwheel and automatically upload to PyPI on every tag
⚠️ This repo is slightly outdated, and these days, there are better examples.
For auto-deployment examples, take a look at the cibuildwheel /examples folder, particularly the Github Deploy example.
cibuildwheel auto-deploy to PyPI example
Travis setup
-
Add an
envsection to your.travis.ymlenv: global: - TWINE_USERNAME=__token__ # Note: TWINE_PASSWORD is set to an API token in Travis settingsInstall
cibuildwheelandtwinein yourinstallsectioninstall: - python -m pip install twine cibuildwheel==x.y.zBuild in the
scriptsectionscript: - python -m cibuildwheel --output-dir wheelhouseFinally, upload if the build was successful
after_success: - if [[ $TRAVIS_TAG ]]; then python -m twine upload wheelhouse/*.whl; fiCheck this repo's .travis.yml as an example.
-
Generate a PyPI API token
-
In the Travis web UI, go to your project settings and add the environment variable
TWINE_PASSWORD, set to your new PyPI API token.
Appveyor setup
-
Add this env to your appveyor.yml
environment: TWINE_USERNAME: __token__ # Note: TWINE_PASSWORD is set in Appveyor settingsAdd this upload step to the
build_script:build_script: - pip install cibuildwheel==x.x.x - cibuildwheel --output-dir wheelhouse - > IF "%APPVEYOR_REPO_TAG%" == "true" ( python -m pip install twine && python -m twine upload wheelhouse/*.whl )Check this repo's appveyor.yml as an example.
-
Generate a PyPI API token
-
In the Appveyor UI, add your new API token as
TWINE_PASSWORD(click Settings > Environment > Add Variable...). Make sure to mark it as private!
On each release
- Bump the version number in
setup.pyand anywhere else it occurs (I usebumpversionfor this) - Commit these changes, tag that commit, and push to Github (don't forget to push the tag!
git push --tags). Your wheels will start building. - Locally, build a source distribution with
rm -rf dist && python setup.py sdist - Upload the source distribution using
twine upload dist/*.tar.gz
Your wheels will build in Travis/Appveyor and push to PyPI when ready.