Repository navigation
build(deps): cap NumPy below 2 in the onnx extra - #947
Conversation
|
Holding this one for a narrower form, and the other three in your set are merged: #945, #946 and #949, plus #948. The diagnosis is right and worth stating again because it is not obvious. My problem is the blast radius of the fix. An environment marker gets the same result without the cost, since the stack this actually affects is identifiable: onnx = ["onnx", "onnxruntime", "onnxscript",
"numpy<2; platform_system == 'Darwin' and platform_machine == 'x86_64'"]That is exactly the macOS Intel checkout from #948, where torch tops out at 2.2.2 and the cap is genuinely required, and it leaves every other platform resolving whatever Either shape is fine by me. Push the marker version and I will merge it, and keep the comment you wrote, since the reason for the constraint is the part nobody would reconstruct later. One correction to the body for whoever reads it next: NumPy 1.26 satisfying onnx, onnxruntime and onnxscript is true today and is the kind of thing that stops being true, so the marker form also means we are not quietly pinning three packages' futures to it. |
`pip install laya[onnx]` resolves `onnx`, whose `ml-dtypes` dependency pulls NumPy 2. torch below 2.3 is built against NumPy 1.x and raises "Numpy is not available" when it converts a tensor against 2.x, which `predict()` needs for its final `.numpy()`. The package declares `torch>=2.0.0`, so the extra should not force a NumPy the declared floor cannot use. Scope the cap with an environment marker rather than a blanket `numpy<2`: a hard upper cap binds every `laya[onnx]` install, including the many on a current torch, and makes the extra unresolvable next to any package that requires `numpy>=2`. The marker names the stack this actually affects -- the macOS/Intel checkout (NandhaKishorM#948), where torch tops out at 2.2.2 and NumPy 1.26 satisfies onnx, onnxruntime and onnxscript anyway.
55e59f2 to
495b590
Compare
|
Pushed the marker form: onnx = ["onnx", "onnxruntime", "onnxscript",
"numpy<2; platform_system == 'Darwin' and platform_machine == 'x86_64'"]The reason comment stays, extended to say why the cap is marker-scoped rather than blanket: the failure at Checked before pushing: the marker evaluates true only for Darwin/x86_64 and false for Darwin/arm64, Linux/x86_64 and Windows/AMD64; |
|
Merged in 0.3.29. This is exactly the form I asked for, and the comment is better than the one I suggested. onnx = ["onnx", "onnxruntime", "onnxscript",
"numpy<2; platform_system == 'Darwin' and platform_machine == 'x86_64'"]The marker names the stack that needs the cap and leaves everyone else resolving what Checking that the marker evaluates true only for Darwin x86_64 and false for Darwin arm64, Linux x86_64 and Windows AMD64 before pushing is the verification this needed, since a marker that is wrong in either direction fails silently: too narrow and the original bug stays, too broad and we are back to the blanket cap with extra steps. Your comment also keeps the point I made about the top end, that NumPy 1.26 satisfying those three packages is true today and is the kind of thing that stops being true, so the marker form means we are not quietly pinning three packages' futures on behalf of one platform. That sentence is the reason the constraint will still make sense to whoever reads it in a year, which is the whole job of a comment on a dependency pin. Thanks for taking the correction on the resolution failure rather than defending the original. That is the half I would have missed if you had not written the diagnosis out first. All 83 suites pass on the merged tree, and this is live in the published 0.3.29 wheel. |
pip install laya[onnx]resolvesonnx, whoseml-dtypesdependency pulls NumPy 2.torch below 2.3 is built against NumPy 1.x and raises "Numpy is not available" when it
converts a tensor against 2.x -- which
predict()needs for its final.numpy().pyproject.tomldeclarestorch>=2.0.0, so the extra should not force a NumPy thedeclared floor cannot use. NumPy 1.26 satisfies onnx, onnxruntime and onnxscript, so the
cap costs the ONNX path nothing.
Found while running the ONNX path on the macOS/Intel stack, which pins torch 2.2.2 and
NumPy 1.26 for exactly this reason.