-
Notifications
You must be signed in to change notification settings - Fork 239
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
feat: arch specifier for GHA #538
Conversation
Testing here: scikit-hep/boost-histogram#474. By the way, wasn't an empty build selection supposed to be an error? |
errrr, I'm not sure I want to do this... with this we have an I'd much rather have clear documentation of how to use cibuildwheel with emulation, that uses |
The benefit here is that since this is an action, we know the user is on GitHub actions, while on the command line, the user can run anywhere. If you'll always be in actions, then we know we can run this. Plus it gives a small benefit to using the action over just running it by hand, especially in a build matrix. Not strongly attached to it, however, partially wanted to see if it was possible.
|
The versions in the examples must not update with bumpversion.py? |
Good catch, updated. bumpversion does update the examples, but if a release is done while the example is in PR, it ends up on an older version. |
I think this is a bit tricky, as we've been saying that I think combining the installation step into the action makes sense, though, but it should be clear that you're enabling QEMU emulation. @joerick has a good point as well, as we don't want to do too many extra things for GHA vs. other CI platforms, I'd say (that's partly the concern of not pushing everyone to the same CI provider and allowing/keeping some diversity, but you also don't know how this will affect |
I'd rather not have However, in the other case, I'd both mildly expect to have a way to set |
PS: If you have an idea of how to get it not to fail without setup-python, that would be appreciated! :) GHA should have python3 on all runners, I think. I believe it was calling "python" without the "3" somewhere and that broke it when I tried it before, I think. |
@joerick The action has Looks like this alone won't fix it. This is the output: macOS: Python 3.9.1, and it works We could, however, use python on windows and python3 on other; which would work at long as ubuntu 20.04 was used (which will be ubuntu-latest soon). But that would require and "if" in powershell on $RUNNER_OS, which I'd have to look up. By the way, I'm not proposing we drop setup-python from the action examples, I'm just looking at improving the experience if someone forgets it. And this discussion is off topic for this PR, as well. |
That's a bit contradictory, though. If it's so easy to set up, why would we add it into the But this was the main point of my objection:
I'm fine with adding |
An action should be self contained; it should not require other actions to run before it (ideally). It can take the input/output of other actions, like checkout, to be composable, but it should stand alone when running. There is no requirement that |
Arguably, This is still ignoring the more important part of |
I want - uses: actions/checkout@v2
- uses: joerick/cibuildwheel@1.8.0
with:
arch: aarch64 To work out of the box without requiring other special actions run beforehand. I would very much expect running this manually, such as: - uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.9'
- uses: docker/setup-qemu-action@v1
with:
image: tonistiigi/binfmt:latest
platforms: all
- name: Install cibuildwheel
run: python -m pip install cibuildwheel==1.8.0
- name: Build wheels
run: python -m cibuildwheel --arch aarch64 To require setup, like installing, setting up Python, setting up arch emulation, etc. We could even always run the docker action enabling emulation, I just think it would be better to have it only run when you pass |
Are we running on ubuntu-20.04 in testing anywhere yet? I see an odd docker image error there (not related to archs). A |
Well, so that's not identical. That's my whole point: If you want to add that to the action, we need something like:
(or
Not that I know of. |
If we just always run the docker run enabling emulation on Linux, then |
Right, now I see the reasoning, thanks :-) |
(Extra example: if I go from GHA to e.g. GitLab, and don't have the action anymore, I suddenly need to do this installation, even though I just translated |
You already need to add the installation of cibuildwheel, you already need to sure you setup python, you already need to ensure docker is available (though it usually is). This is just one more spot where the action, being an action, can bundle things together to provide a nice user experience. For arbitrary systems, you might not even want to use the docker install step: https://wiki.debian.org/QemuUserEmulation. And if GitHub Actions installed what was needed by default eventually, we could just use that and drop the docker run in the action. Currently working on seeing if I can get the action to run without requiring setup-python, as that should be possible, even if we continue to recommend setup-python runs first. |
We could add it as a different named option, or we can just leave it off for now. I just think if passed it should run any setup it requires.
It doesn't affect that at all, because it literally just passes this on to |
Wait, I'm not getting this. It would be different, right? Because in that case, you need to install a cross-compiler, rather than QEMU. So passing that as |
Also, if for Debian, |
No, the argument is we are just doing what the setup-qemu-action does. Imagine for a moment that GitHub Composite actions allowed other Actions in the composite. Then I think it would be completely natural to add the
No, it can't be different, it is just passing this through directly to cibuildwheel with no modifications at all. What happens if someone ran a QEMU setup action earlier for some other reason? Or GHA enabled it by default? cibuildwheel can't make a decision to cross-compile vs. emulate based on the fact that QEMU is available; it has to be some other way or flag. However that works, it will work here too. The only difference is that we know we are an action on GHA, so we can make sure this never fails for a user since we know exactly what setup is needed. Actions shouldn't require other setup actions if possible. For example, pre-commit/action used to require the cache action, and it was a mess, so pre-commit/action 2.0.0 does it's own caching, and it's far better and simpler. My point is that a GitHub Action should not require another GitHub Action to be run beforehand. So if there's an exposed setting to enable archs, that should not fail out of the box without special setup. I'm not strongly against adding a I'm totally fine to avoid adding this option for now to the action - if we didn't add it as command line flag but only added it as a variable, we would likely not be having this discussion. :) |
@@ -185,7 +185,7 @@ def main() -> None: | |||
print('cibuildwheel: Could not find setup.py, setup.cfg or pyproject.toml at root of package', file=sys.stderr) | |||
exit(2) | |||
|
|||
if args.archs is not None: | |||
if args.archs: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm in favor of this change, though, since it lets --archs=""
be ignored, which makes logic like that above simpler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be hiding configuration mistakes, though. --archs=$TYPO_ENV_VAR
or --archs=${{ matrix.bad_conf_var }}
or so.
(Not sure what I think is best, but I think it's an important thing to note about this change.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair point. I could just do the extra bash logic to add the --arch
if non-empty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, though it might be nice behavior to our users, as well, as you demonstrated a use case. I'm not sure what's optimal, here.
(Not to worried about making our one time use in the action slightly uglier, actually :-p )
No, but now you're interpreting the |
No, this is a perfectly valid implementation: - run: |
if [[ "$RUNNER_OS" == "Linux" ]] ; then
docker run --privileged --rm tonistiigi/binfmt --install all
fi
shell: bash
- run: python3 -m cibuildwheel ${{ inputs.package-dir }} --output-dir ${{ inputs.output-dir }} --archs "${{ inputs.archs }}"
shell: bash This does not infer anything at all on |
It ís a perfectly valid implementation of the
|
This is what's triggering the emulation: 'aarch64': 'quay.io/pypa/manylinux2014_aarch64:2020-12-31-56195b3' It tries to load this image and if you don't run this step first, it fails. If we add a way to cross compile, it will load a x86_64 image instead and this will be fine. And if you do cross compile, you would still load an emulated image to test, so I don't see how adding this to the action would hurt cross compiling. You have to be able to cross compile and load emulated architectures too, and you can't decide based on if it is possible to emulate. I think a GitHub Action that might load emulated images should set up emulation for you if it reasonably can. Just like an action that caches should set that up for you. |
Unrelated, but too small to stick in an issue (yet): Do we support running from
|
Of course, I see all that. But I don't think that warrants the introduction of a different meaning to Let's take a different example, then: suppose I have an image with QEMU and |
Heh? Never really tried, but ... it should, no? |
I'm trying to get the action to work without setup-python, and to do so, I need to have an if, so I combined everything into a single powershell action (powershell is needed due to the a path using backslashes). But this breaks cibuildwheel, which I don't think it should. It seems that it's using bash-specific syntax internally, perhaps, and it loads a different shell when used from powershell? Just a wild guess. I need to ensure that a normal run would trigger it, but don't see why it wouldn't, the composite action is just a run with a shell. I don't need to combine them, and I could avoid this - but it seems like we should not be shell specific. |
Hmm, do you have a log? On which platform are things breaking, on Linux?
Right, because bash is run inside WSL2... |
Wait, no probably not. It's the opposite direction. It's powershell on Linux... :-( |
Heh. Everything inside that Docker should run in |
Wait. You don't have a docker image in this command?
Somehow the correct Docker image is not being picked up? |
Sorry! My mistake. Not powershell's fault at all. I somehow managed to delete the image setting in my matrix, so it's setting the images to an empty string. 🤦 Would it be useful to have a check for an empty image string in cibuildwheel? (Same bug as warned about in the change to Edit: changed ubuntu-latest to ubuntu-20.04 but did not update the |
Makes sens to me, yes! We have a few of these warnings (or even errors) already :-) |
Maybe we can eventually come back to this, but after #542, there are no side effects, while this would have a side effect (QEMU enabled after the action is run), so I'm not so sure it's ideal. I'd still be in favor, I think, but not enough to tip any scales if others are opposed. |
Follow up to #482, mentioned in #416.
Would it be better to loop through the archs and install them one by one? Not sure what's best with running this container.