Skip to content
Example repo showing how to build wheels with cibuildwheel and automatically upload to PyPI on every tag
C Python
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

cibuildwheel auto-deploy to PyPI example

Travis setup

  • Add an env section to your .travis.yml

        - TWINE_USERNAME=...your pypi username...
        # Note: TWINE_PASSWORD is set in Travis settings

    Install cibuildwheel and twine in your install section

      - python -m pip install twine cibuildwheel==x.y.z

    Build in the script section

      - python -m cibuildwheel --output-dir wheelhouse

    Finally, upload if the build was successful

       - if [[ $TRAVIS_TAG ]]; then python -m twine upload wheelhouse/*.whl; fi

    Check this repo's .travis.yml as an example.

  • In the Travis web UI, go to your project settings and add the environment variable TWINE_PASSWORD, set to your PyPI password.

Appveyor setup

  • Add this env to your appveyor.yml

      TWINE_USERNAME: ...your pypi username...
      # Note: TWINE_PASSWORD is set in Appveyor settings

    Add this upload step to the 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.

  • In the Appveyor UI, add your PyPI password as TWINE_PASSWORD (click Settings > Environment > Add Variable...). Make sure to mark it as private!

On each release

  • Bump the version number in and anywhere else it occurs (I use bumpversion for 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 sdist
  • Upload the source distribution using twine upload dist/*.tar.gz

Your wheels will build in Travis/Appveyor and push to PyPI when ready.

You can’t perform that action at this time.