BLD Uses cibuildwheel for linux + osx wheels [cd build]#20102
BLD Uses cibuildwheel for linux + osx wheels [cd build]#20102mattip merged 16 commits intonumpy:mainfrom
Conversation
|
Is there a reason you are doing this here rather than at Macpython/numpy-wheels ? |
| NPY_USE_BLAS_ILP64: 1 | ||
| CIBW_BUILD: cp${{ matrix.python }}-${{ matrix.platform }} | ||
| CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 | ||
| CIBW_ENVIRONMENT_LINUX: CFLAGS='-std=c99 -fno-strict-aliasing' |
There was a problem hiding this comment.
Is -std=c99 definitely needed for the newer compilers? IIRC, there was some discussion that might disable some newer features.
There was a problem hiding this comment.
It's only needed for GCC 4.x IIRC, and we should drop that now that we no longer need manylinux1.
There was a problem hiding this comment.
Although we should separate dropping that, and not mix it with a CI reshuffle - so the flag is best kept as is here.
There was a problem hiding this comment.
how will we remember to do this?
There are some benefits of moving it to
I am also okay with moving this over to CC @rgommers Do you have thoughts on moving wheel building to |
This reverts commit 9b45d83.
I think it's time for that. The one advantage of MacPython/numpy-wheels is that we have TravisCI credits there for aarch64/ppc64le builds. But other than that I think it mostly has downsides: hard to discover, more effort to maintain and search for issues because of the split over repos, not enough people paying attention to broken CI because it's a separate repo, etc. We also never intended the repo to be under MacPython, that's an accident of history. There's a separate question about auto-uploading to PyPI - I know some other projects like it, but I'm still weary of that. Uploading to the Anaconda staging bucket, and having the release manager download those and re-upload when they're ready seems safer to me both release mechanics wise and security wise (e.g., recent codecov security breach exposed secrets). |
|
Thanks a lot for working on this @thomasjpfan! Moving to cibuildwheel will be valuable long-term. |
tools/wheels/cibw_before_build.sh
Outdated
|
|
||
| # Install GFortran | ||
| if [[ $UNAME == "Darwin" ]]; then | ||
| # same version of gfortran as the open-libs and numpy-wheel builds |
There was a problem hiding this comment.
typo: open-libs -> openblas-libs
| NPY_USE_BLAS_ILP64: 1 | ||
| CIBW_BUILD: cp${{ matrix.python }}-${{ matrix.platform }} | ||
| CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 | ||
| CIBW_ENVIRONMENT_LINUX: CFLAGS='-std=c99 -fno-strict-aliasing' |
There was a problem hiding this comment.
Although we should separate dropping that, and not mix it with a CI reshuffle - so the flag is best kept as is here.
rgommers
left a comment
There was a problem hiding this comment.
This looks like it will be a very pleasant change of pace, no more bash & submodules:)
.github/workflows/wheels.yml
Outdated
|
|
||
| on: | ||
| schedule: | ||
| # Nightly build at 1:42 A.M. |
| with: | ||
| submodules: true | ||
| # The complete history is required for versioneer.py to work | ||
| fetch-depth: 0 |
There was a problem hiding this comment.
I don't think it is - we just need enough commits to have the previous tag. In gitpod.Dockerfile it does git clone --shallow-since=2021-05-22
There was a problem hiding this comment.
I think this is right. You need enough to get to the tag that started the current version. It is hard to get it right in a maintenance free way. Once could alternatively assume that NumPy will always have fewer than XXXX commits between releases, and then use that.
There was a problem hiding this comment.
We tried the "guess the number of commits" and have been wrong before - so probably using the date and bumping it once a year is easier/safer.
There was a problem hiding this comment.
I can't find a simple way to get the git describe (versioneer.py) to work with shallow clones:
git clone --shallow-since=2021-05-22 https://github.com/numpy/numpy
cd numpy
git describe
# fatal: No names found, cannot describe anything.Currently, a possible solution is:
git clone --depth=1 https://github.com/thomasjpfan/numpy numpy
cd numpy
# pulls in branch with tags
git fetch --prune origin +d8922518c4ec66d91d16e5549bd9b9390cfee678:refs/remotes/origin/ci_buildwheel_rf_shallow
# checkout branch
git checkout --progress -B ci_buildwheel_rf_shallow refs/remotes/origin/ci_buildwheel_rf_shallow
git describe
# v1.22.0.dev0-1425-gd8922518cI feel like that is a bit too complex compare to fetch-depth: 0.
Note: There is an open issue to get this workflow to work: actions/checkout#338
There was a problem hiding this comment.
Agreed that that's too complex - so +1 for doing whatever is simplest here.
I can't find a simple way to get the
git describe(versioneer.py) to work with shallow clones:
versioneer continues to be a pain:(
There was a problem hiding this comment.
For this PR, I think we leave fetch-depth: 0 for now until actions/checkout#338 gets resolved. It currently takes ~ 14 seconds to fetch the entire history, so I think it is okay for the time being.
There was a problem hiding this comment.
I note that --shallow-exclude=v1.21.0.dev0 works. Unfortunately, --shallow-exclude=v1.22.0.dev0^ doesn't.
.github/workflows/wheels.yml
Outdated
| CIBW_BEFORE_TEST: pip install -r {project}/test_requirements.txt | ||
| # Installs libffi so that cffi can be built from source when needed | ||
| CIBW_BEFORE_TEST_LINUX: > | ||
| [[ "${{ matrix.install_libffi_devel }}" == "1" ]] && yum install -y libffi-devel; |
There was a problem hiding this comment.
What do we use libffi-devel for, just some optional tests or something more interesting?
There was a problem hiding this comment.
libffi-devel is used to build cffi from source if wheels do not exists. cffi is required by test_requirements here:
Lines 9 to 10 in e869222
There was a problem hiding this comment.
It would be fine to make cffi a soft requirement: if it is unavailable we could skip that test. Is there a way to do that without too much hassle? The test takes the failed import into account
numpy/numpy/random/tests/test_extending.py
Lines 9 to 13 in e869222
There was a problem hiding this comment.
Updated test_requirements.txt, to make cffi a soft requirement for python 3.10:
cffi; python_version < '3.10'
If PyPI implements draft releases (GitHub PR) (Discourse topic), you could switch to PyPI for this workflow |
A follow up to this PR is to upload to an Anaconda staging bucket. From there you can follow your current release workflow of downloading and re-uploaded. |
| with: | ||
| submodules: true | ||
| # The complete history is required for versioneer.py to work | ||
| fetch-depth: 0 |
| NPY_USE_BLAS_ILP64: 1 | ||
| CIBW_BUILD: cp${{ matrix.python }}-${{ matrix.platform }} | ||
| CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 | ||
| CIBW_ENVIRONMENT_LINUX: CFLAGS='-std=c99 -fno-strict-aliasing' |
There was a problem hiding this comment.
how will we remember to do this?
|
One last thing: it would be good to document the |
|
We discussed this at the weekly triage meeting. One workflow that is not clear is the desire to kick off all the different CI that will be used to build wheels against a commit (This PR uses github actions. Currently travis-ci is used for arm64, ppc64le, and s390x. We have concerns that the arm64 builds on travis are flaky and are looking for alternatives, so we may end up with a third CI service). Since we use at least two services, a button to trigger builds on github actions would not be sufficient to complete the task. Currently, the MacPython/numpy-wheels workflow allows us to make a commit to that repo, which then pulls the appropriate commit from here and builds a wheel. If we merge this PR to numpy/numpy, then we could continue with that idea: make a commit to trigger wheel building. But then that commit will become part of the permanent numpy git history. Is that the way other projects use cibuildwheel? There is also some concern that a run of this CI job will push wheels to anaconda.org, these would be marked as the "latest dev wheels" and picked up by projects building off of latest NumPy wheels. It seems that is a bit too open. Is there a way to limit the ability to upload? |
For triggering a build on another service for a specific PR, we can have a button to trigger builds in github actions that calls the other CI services' API to trigger the build. Another option is to manually trigger a build for a specific commit in the CI services' UI.
I think every project is a little different on how they use
There are ways to limit the upload. What kind of limits are you thinking of? |
|
@charris - thoughts? |
|
FYI |
|
In recent community/triage discussions we decided to put this in. TBD:
I would like to put this in as-is and do the rest in future PRs. Does that make sense? |
|
Thanks @thomasjpfan |
Your plan looks good to me. |
Related to MacPython/numpy-wheels#116
This PR:
[cd build]is in the commit message, where "cd" means "continuous delivery"I kept this PR small by only supporting two platforms. Follow up includes:
Note: The big diff comes from the licenses that was copied over from numpy-wheels.