You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* docs: add tips for numpy
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
* docs: update example for numpy 2.3.0
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
* Update docs/faq.md
---------
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
Copy file name to clipboardExpand all lines: docs/faq.md
+50Lines changed: 50 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -49,6 +49,56 @@ myextension = Extension(
49
49
)
50
50
```
51
51
52
+
### Building with NumPy
53
+
54
+
If using NumPy, there are a couple of things that can help.
55
+
56
+
First, if you require the `numpy` package at build-time (some binding tools, like `pybind11` and `nanobind`, do not), then the backward compatibility for your `build-backend.build-requires` is a little complicated for Python <3.9:
57
+
58
+
* NumPy <1.25: You must build with the oldest version of NumPy you want to support at runtime.
59
+
* NumPy 1.25 and 1.26: Anything you build will be compatible with 1.19+ by default, and you can set the minimum target to, for example, 1.22 with `#define NPY_TARGET_VERSION NPY_1_22_API_VERSION`.
60
+
* NumPy 2.x: You must build with NumPy 2 to support NumPy 2; otherwise the same as 1.25+.
61
+
62
+
So the rule is:
63
+
64
+
* Python <3.8: Use the oldest supported NumPy (via helper `oldest-supported-numpy` if you want)
65
+
* Python 3.9+: Use latest supported NumPy (2+).
66
+
67
+
Second, there might be platforms you want to ship for that NumPy (or some other scientific Python libraries) are not shipping yet for. This is often true for beta candidates of new Python releases, for example. To work with this, you can use the Scientific Python Nightly wheels. Here's an example, depending on what frontend you use:
68
+
69
+
!!! tab "pip based"
70
+
For frontends like `build` (the default) and `pip`:
(Note the `*_ONLY_BINARY` variable also supports `":all:"`, and you don't need both that and `*_PREFER_BINARY`, you can use either one, depending on if you want a missing wheel to be a failure or an attempt to build in CI.)
101
+
52
102
### Automatic updates using Dependabot {: #automatic-updates}
53
103
54
104
Selecting a moving target (like the latest release) is generally a bad idea in CI. If something breaks, you can't tell whether it was your code or an upstream update that caused the breakage, and in a worst-case scenario, it could occur during a release.
0 commit comments