From 190b013c61d66f6ef5817f268bfb53cc14e7a34b Mon Sep 17 00:00:00 2001 From: Seth Morton Date: Mon, 25 Nov 2019 12:43:26 -0800 Subject: [PATCH 1/2] Update Travis CI examples For a more granular view of why each of these changes were made, please see https://github.com/joerick/cibuildwheel-autopypi-example/pull/5. High-level overview: - Adding Windows support - Remove "sudo: required" for linux - Use "python -m pip" instead of using an environment variable - Add "install:" and "after_success:" steps so that errors get handled and reported properly - Rename "matrix:" to "jobs:" as this is the now preferred keyword --- README.md | 32 ++++++++++++++++---------------- docs/setup.md | 42 ++++++++++++++++++++++-------------------- 2 files changed, 38 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index 050b8a55..818d2a32 100644 --- a/README.md +++ b/README.md @@ -48,40 +48,40 @@ Usage Example setup ------------- -To build manylinux and macOS wheels on Travis CI, and upload them to PyPI whenever you tag a version, you could use this `.travis.yml`: +To build manylinux, macOS, and Windows wheels on Travis CI and upload them to PyPI whenever you tag a version, you could use this `.travis.yml`: ```yaml language: python -matrix: +jobs: include: # perform a linux build - - sudo: required - services: - - docker - env: PIP=pip + - services: docker # and a mac build - os: osx - language: generic - env: PIP=pip2 + language: shell + # and a windows build + - os: windows + language: shell + before_install: + - choco install python --version 3.8.0 + - export PATH="/c/Python38:/c/Python38/Scripts:$PATH" env: global: - TWINE_USERNAME=joerick # Note: TWINE_PASSWORD is set in Travis settings +install: + - python -m pip install twine cibuildwheel==1.0.0 + script: - - $PIP install cibuildwheel==1.0.0 - # build the wheels, put them into './wheelhouse' - - cibuildwheel --output-dir wheelhouse + - python -m cibuildwheel --output-dir wheelhouse +after_success: # if the release was tagged, upload them to PyPI - - | - if [[ $TRAVIS_TAG ]]; then - python -m pip install twine - python -m twine upload wheelhouse/*.whl - fi + - if [[ $TRAVIS_TAG ]]; then python -m twine upload wheelhouse/*.whl; fi ``` For more information, including how to build on Appveyor, Azure, CircleCI, check out the [documentation](https://cibuildwheel.readthedocs.org). diff --git a/docs/setup.md b/docs/setup.md index fd387a32..05a4523c 100644 --- a/docs/setup.md +++ b/docs/setup.md @@ -47,37 +47,39 @@ Commit this file, enable building of your repo on Azure Pipelines, and push. Wheels will be stored for you and available through the Pipelines interface. For more info on this file, check out the [docs](https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema). -# Travis CI [linux/mac] {: #travis-ci} +# Travis CI [linux/mac/windows] {: #travis-ci} -To build Linux and Mac wheels on Travis CI, create a `.travis.yml` file in your repo. +To build Linux, Mac, and Windows wheels on Travis CI, create a `.travis.yml` file in your repo. > .travis.yml ```yaml language: python -matrix: +jobs: include: - - sudo: required - services: - - docker - env: PIP=pip + # perform a linux build + - services: docker + # and a mac build - os: osx - language: generic - env: PIP=pip2 - -script: - - $PIP install cibuildwheel==1.0.0 - - cibuildwheel --output-dir wheelhouse -``` - -To build on Windows too, add this matrix entry: -```yaml + language: shell + # and a windows build - os: windows language: shell before_install: - - choco install python3 --version 3.6.8 --no-progress -y - env: - - PATH=/c/Python36:/c/Python36/Scripts:$PATH + - choco install python --version 3.8.0 + - export PATH="/c/Python38:/c/Python38/Scripts:$PATH" + +env: + global: + - TWINE_USERNAME=joerick + # Note: TWINE_PASSWORD is set in Travis settings + +install: + - python -m pip install twine cibuildwheel==1.0.0 + +script: + # build the wheels, put them into './wheelhouse' + - python -m cibuildwheel --output-dir wheelhouse ``` Note that building Windows Python 2.7 wheels on Travis is unsupported. From 20ba988b721970f1994072c035a57107068f00b4 Mon Sep 17 00:00:00 2001 From: Seth Morton Date: Mon, 25 Nov 2019 18:59:07 -0800 Subject: [PATCH 2/2] Add an example folder with Travis-CI examples I have placed two example Travis-CI configurations in an examples/ folder. The first is the same as in the README, and the second shows how to both test and deploy in two stages. I am hoping that examples might be added for other CI providers as well, so that users can see different approaches to building and deploying wheels. --- README.md | 2 +- examples/travis-ci-deploy-only.yml | 34 ++++++++++++ examples/travis-ci-test-and-deploy.yml | 77 ++++++++++++++++++++++++++ 3 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 examples/travis-ci-deploy-only.yml create mode 100644 examples/travis-ci-test-and-deploy.yml diff --git a/README.md b/README.md index 818d2a32..ae2800a0 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ after_success: - if [[ $TRAVIS_TAG ]]; then python -m twine upload wheelhouse/*.whl; fi ``` -For more information, including how to build on Appveyor, Azure, CircleCI, check out the [documentation](https://cibuildwheel.readthedocs.org). +For more information, including how to build on Appveyor, Azure, CircleCI, check out the [documentation](https://cibuildwheel.readthedocs.org) and also check out [the examples](https://github.com/joerick/cibuildwheel/tree/master/examples). Options ------- diff --git a/examples/travis-ci-deploy-only.yml b/examples/travis-ci-deploy-only.yml new file mode 100644 index 00000000..e0ace8d9 --- /dev/null +++ b/examples/travis-ci-deploy-only.yml @@ -0,0 +1,34 @@ +# As written, this configuration will build your wheels on every +# commit, but will only push to PyPI on tagged commits. + +language: python + +jobs: + include: + # perform a linux build + - services: docker + # and a mac build + - os: osx + language: shell + # and a windows build + - os: windows + language: shell + before_install: + - choco install python --version 3.8.0 + - export PATH="/c/Python38:/c/Python38/Scripts:$PATH" + +env: + global: + - TWINE_USERNAME=joerick + # Note: TWINE_PASSWORD is set in Travis settings + +install: + - python -m pip install twine cibuildwheel==1.0.0 + +script: + # build the wheels, put them into './wheelhouse' + - python -m cibuildwheel --output-dir wheelhouse + +after_success: + # if the release was tagged, upload them to PyPI + - if [[ $TRAVIS_TAG ]]; then python -m twine upload wheelhouse/*.whl; fi diff --git a/examples/travis-ci-test-and-deploy.yml b/examples/travis-ci-test-and-deploy.yml new file mode 100644 index 00000000..9a31da96 --- /dev/null +++ b/examples/travis-ci-test-and-deploy.yml @@ -0,0 +1,77 @@ +# In this configuration, the package is tested against multiple versions of python +# on Linux and on one version of Python on Windows. If and only if all tests pass +# will the wheels be built and deployed. Further, deployment is only initiated if +# the current branch is "master", the current commit is tagged, and the current +# repo is yours (e.g. it won't run on a Pull Request). For convenience, a source +# distribution is also created. + +language: python +python: + - 3.5 + - 3.6 + - 3.7 + - 3.8 + +before_install: + - | + if [[ "$TRAVIS_OS_NAME" = windows ]]; then + choco install python --version 3.8.0 + export PATH="/c/Python38:/c/Python38/Scripts:$PATH" + fi + +install: + - python -m pip install pytest + +script: + - python setup.py install + - pytest + +stages: + - test + # Only execute deployment stage on master branch, tagged commits, + # and from your repository (e.g. not PRs). Replace with your repo name. + - name: deploy + if: branch = master AND tag IS PRESENT AND repo = joerick/cibuildwheel + +jobs: + include: + # Optional: run a test on Windows + - os: windows + language: shell + name: Test on Windows + + # Deploy source distribution + - stage: deploy + name: Deploy source distribution + install: skip + script: python setup.py sdist --formats=gztar + after_success: python -m twine upload --skip-existing dist/*.tar.gz + # Deploy on linux + - stage: deploy + name: Build and deploy Linux wheels + services: docker + install: python -m pip install twine cibuildwheel==1.0.0 + script: python -m cibuildwheel --output-dir wheelhouse + after_success: python -m twine upload --skip-existing wheelhouse/*.whl + # Deploy on mac + - stage: deploy + name: Build and deploy macOS wheels + os: osx + language: shell + install: python -m pip install twine cibuildwheel==1.0.0 + script: python -m cibuildwheel --output-dir wheelhouse + after_success: python -m twine upload --skip-existing wheelhouse/*.whl + # Deploy on windows + - stage: deploy + name: Build and deploy Windows wheels + os: windows + language: shell + install: python -m pip install twine cibuildwheel==1.0.0 + script: python -m cibuildwheel --output-dir wheelhouse + after_success: python -m twine upload --skip-existing wheelhouse/*.whl + +env: + global: + - TWINE_USERNAME=joerick + # Note: TWINE_PASSWORD is set in Travis settings +