Best practices for packages built against the numpy C API?

So I’ve got a few packages I maintain that are C (Cython) code that uses the numpy C API.

I’ve lost track of how to best handle this, so they will get pinned to compatible numpy version.

I think we used to do numpy = *.* (Or was it x.y?), and the CI would build a matrix.

But with 2.0, I think that there’s a backwards compatible API, so that if I do:

  host:
     - numpy >=2

then it will build against 2.0, and should run with any (not ancient) numpy – is that right?

Anyway, is this documented somewhere?

The transition to numpy v2 is being done with a migration available at conda-forge-pinning-feedstock/recipe/migrations/numpy2.yaml at main · conda-forge/conda-forge-pinning-feedstock · GitHub. This file contains the description of the PR that would be created when your feedstocks receive the migration. You can check how the queue / tree looks like at https://conda-forge.org/status/migration/numpy2 (Table view; click on the colored menus to enable/disable sections).

The gist is:

  • The migration file should be placed under .ci_support/migrations.
  • The host section should just mention numpy (no version constraints)
  • The run section does not need anything because of the run_exports settings
  • Rerender et voilà

Hmm – however, I can’t find either of the packages I’m working on on the list anywhere, and they have not received a PR.

(py_gd and mapbox-earcut)

In any case, py_gd has gotten an upstream update, and I’m trying to update the recipe so it will work with numpy2.

Meanwhile the bot auto created a PR that built it with a bunch of numpy versions, but not 2.0.

So I’m still not clear what to do – is there documentation for what to do for a new recipe somewhere?

Or is it as simple as:

Put numpy, with no pinning in:

build, host, and run ?

and the CI will take care of it all?

Thanks,

PS: putting {{ stdlib('c') }} in the build requirements is breaking things for me too – but that’s another issue …

AARRGGH! never mind – py_gd did get a build fro numpy2.0 PR – no idea how I missed that!

OK – py_gd now good – I merged the numpy2.0 update, then did a PR for the new version, and all good.

However, mapbox-earcut is building for numerous numpy versions, rather than 2.0:

How do I get the “new style” build?

Uwe replied there, but for sake of completeness:

  1. Place the numpy2.yaml migration file under .ci_support/migrations
  2. Rerender

and to put it all on one place, you can find numpy2.yaml here:

and that worked for me – thanks!