Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build wheels for variety of platforms using cibuildwheel #109

Merged
merged 4 commits into from
Oct 18, 2021

Conversation

kylebarron
Copy link
Contributor

@kylebarron kylebarron commented Aug 11, 2021

I just came across this project and saw #25. I've set up building wheels on CI for a variety of projects so figured I'd send over a quick PR. This PR provides a working demo of using cibuildwheel to build wheels on CI for a matrix of Python 3.6 through 3.9, PyPy, CPython, Windows, Linux, Mac, and Mac ARM.

Example output from this Github Actions run: artifact.zip (you can only download output if it's your own repo I think)

Contains these files:

ciso8601-2.2.0-cp36-cp36m-macosx_10_9_x86_64.whl
ciso8601-2.2.0-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
ciso8601-2.2.0-cp36-cp36m-win_amd64.whl
ciso8601-2.2.0-cp37-cp37m-macosx_10_9_x86_64.whl
ciso8601-2.2.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
ciso8601-2.2.0-cp37-cp37m-win_amd64.whl
ciso8601-2.2.0-cp38-cp38-macosx_10_9_universal2.whl
ciso8601-2.2.0-cp38-cp38-macosx_10_9_x86_64.whl
ciso8601-2.2.0-cp38-cp38-macosx_11_0_arm64.whl
ciso8601-2.2.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
ciso8601-2.2.0-cp38-cp38-win_amd64.whl
ciso8601-2.2.0-cp39-cp39-macosx_10_9_universal2.whl
ciso8601-2.2.0-cp39-cp39-macosx_10_9_x86_64.whl
ciso8601-2.2.0-cp39-cp39-macosx_11_0_arm64.whl
ciso8601-2.2.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
ciso8601-2.2.0-cp39-cp39-win_amd64.whl
ciso8601-2.2.0-pp37-pypy37_pp73-macosx_10_9_x86_64.whl
ciso8601-2.2.0-pp37-pypy37_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
ciso8601-2.2.0-pp37-pypy37_pp73-win_amd64.whl
ciso8601-2.2.0.tar.gz

Notes:

  • cibuildwheel was somewhat recently added to the pypa organization, so it's likely to be well maintained into the future.
  • cibuildwheel v2 doesn't support deprecated Python versions such as Python 2.7 or 3.5. So the wheels built are for Python 3.6+.
  • I see you currently use CircleCI. cibuildwheel supports CircleCI, but only on Linux and MacOS, and doesn't support Windows. I've used Github Actions more, so it was both faster to provide a demo using that and it also shows that you can build Mac, Windows, and Linux wheels with it.
  • To test, you can download the wheel for your platform/Python version and call pip install ./abc.whl.

Ref: #97

Comment on lines +6 to +7
# tags:
# - 'v*'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On my repos I have this uncommented so that it only runs when I push a newly tagged release.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just out of curiousity: Is there a reason to use push instead of the release event?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure when the release event is called. Does pushing a new tag create a release? Or do you have to make a "release" manually through the Github UI?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that it happens when:

  • A person manually makes/modifies a release in GitHub (releases/new)
  • Or it is done via the releases API

Docs on the release webhook event

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting! I've never researched that before. It just occurred to me you'd likely be able to do the same things with the github cli:

> gh release create --help
Create a new GitHub Release for a repository.

A list of asset files may be given to upload to the new release. To define a
display label for an asset, append text starting with `#` after the file name.

If a matching git tag does not yet exist, one will automatically get created
from the latest state of the default branch. Use `--target` to override this.
To fetch the new tag locally after the release, do `git fetch --tags origin`.

To create a release from an annotated git tag, first create one locally with
git, push the tag to GitHub, then run this command.


USAGE
  gh release create <tag> [<files>...]

FLAGS
  -d, --draft             Save the release as a draft instead of publishing it
  -n, --notes string      Release notes
  -F, --notes-file file   Read release notes from file
  -p, --prerelease        Mark the release as a prerelease
      --target branch     Target branch or full commit SHA (default: main branch)
  -t, --title string      Release title

INHERITED FLAGS
      --help                     Show help for command
  -R, --repo [HOST/]OWNER/REPO   Select another repository using the [HOST/]OWNER/REPO format

EXAMPLES
  Interactively create a release
  $ gh release create v1.2.3

  Non-interactively create a release
  $ gh release create v1.2.3 --notes "bugfix release"

  Use release notes from a file
  $ gh release create v1.2.3 -F changelog.md

  Upload all tarballs in a directory as release assets
  $ gh release create v1.2.3 ./dist/*.tgz

  Upload a release asset with a display label
  $ gh release create v1.2.3 '/path/to/asset.zip#My display label'

LEARN MORE
  Use 'gh <command> <subcommand> --help' for more information about a command.
  Read the manual at https://cli.github.com/manual

Comment on lines +48 to +61
# upload_pypi:
# needs: [build_wheels, build_sdist]
# runs-on: ubuntu-latest
# steps:
# - uses: actions/download-artifact@v2
# with:
# name: artifact
# path: dist
#
# - uses: pypa/gh-action-pypi-publish@master
# with:
# user: __token__
# password: ${{ secrets.PYPI_PASSWORD }}
# # To test: repository_url: https://test.pypi.org/legacy/
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will automatically push a new release to PyPI if uncommented. You need to add an api token for this specific PyPI project to Github Actions' secrets.

Copy link
Collaborator

@movermeyer movermeyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kylebarron This looks really cool. ✨ I think this is good enough to merge for now. I'll probably end up customizing it a bit to add some additional checks and/or triggers, but this is a great starting point for me. 😍

Thanks for doing this (especially bringing cibuildwheel to my attention. It seems like a much better solution than using manylinux directly. 🙌 🙇

@movermeyer movermeyer merged commit 9d3f037 into closeio:master Oct 18, 2021
@kylebarron
Copy link
Contributor Author

Yeah I expected that you'd want to customize this a bit. cibuildwheel is really amazing. Definitely seems better than a manual approach

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants