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

Feature Request: flag to skip build if there is not a numpy wheel available #1701

Open
fgregg opened this issue Dec 16, 2023 · 2 comments
Open

Comments

@fgregg
Copy link
Contributor

fgregg commented Dec 16, 2023

Description

A great many C extensions depend upon numpy.

If numpy does not have a binary wheel targeting that platform, version, and architecture, then almost always it is going to be harder for the user to compile numpy from source than the dependent library.

It would be great to add a environmental flag to avoid building wheels for when there is not already a numpy wheel available.

This could be accomplished by either trying to do the build, and bailing out if pip finds there is no wheel available. Alternately, we could use the pypi API to look at all the numpy wheels available in the most recent version of numpy and deduce what to skip.

Almost all the the things i'm skipping in CIBW_SKIP are because of missing numpy wheels.

@joerick
Copy link
Contributor

joerick commented Jan 26, 2024

I wonder if a lot of people have the same issue. It's kinda advanced but I wonder if a neat syntax for this would be something like CIBW_SKIP_IF_FAIL or CIBW_SKIP_UNLESS e.g. CIBW_SKIP_UNLESS=pip install --only-binary :all: numpy. Might be worth considering if lots of people would find it useful.

@alexlancaster
Copy link

alexlancaster commented Jan 30, 2024

I wonder if a lot of people have the same issue. It's kinda advanced but I wonder if a neat syntax for this would be something like CIBW_SKIP_IF_FAIL or CIBW_SKIP_UNLESS e.g. CIBW_SKIP_UNLESS=pip install --only-binary :all: numpy. Might be worth considering if lots of people would find it useful.

I like this idea!

I think this would be quite a common use-case. For my project pypop which depends on numpy as an install and test-time dependency, I try and build as many wheels as possible using cibuildwheel that will work for the end-user. But, specifically not building wheels for pypop that might require a dependency (like numpy) to be built from source during installation. That way lies disappointment for the majority of end-users.

But as the status numpy wheels for particular architecture changes (normally more are added), I have to resort-to-trial and error to converge on the exact set of exclusions in skip I need to add to pyproject.toml. Here is my process:

  1. start with not skipping any wheels, build all possible wheels, note the failures, especially due to numpy
  2. add the failed versions due to missing numpy wheels to skip in [tool.cibuildwheel]
  3. periodically check numpy pypi for new wheels if a new wheel is now provided, remove them from from skip.
  4. re-run

Running the full workflow just to check whether a new wheel is error-prone, and dependent on when I think to look at pypi. It would be much better to have it be dynamic, as suggested above with a new CIBW_SKIP_UNLESS (or skip_unless within pyproject.toml). That way, I would only need to include in the skip builds that fail due to reasons like a fundamental architecture incompatibility or similar, rather than skipping wheels that don't install because of the vaguaries of whether the upstream pypi project happens to build that wheel at this moment.

I'm not sure how easy this would be, but it would also be nice if it could be integrated into the parallel-style of cibuildwheel on github action as shown in https://iscinumpy.dev/post/cibuildwheel-2-10-0/. in other words, it would be useful if the CIBW_SKIP_UNLESS could be provided in the generate_wheels github job, so that it would skip the generation of the wheel option in that job, rather than being skipped in the actual build wheel step, so it wouldn't generate empty jobs.

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

No branches or pull requests

3 participants