Skip to content

MAINT: cast linear_sum_assignment to PyCFunction#16934

Merged
rgommers merged 1 commit intoscipy:mainfrom
hoodmane:linear-sum-pycfunction
Aug 31, 2022
Merged

MAINT: cast linear_sum_assignment to PyCFunction#16934
rgommers merged 1 commit intoscipy:mainfrom
hoodmane:linear-sum-pycfunction

Conversation

@hoodmane
Copy link
Copy Markdown
Contributor

One more -Wincompatible-function-pointer-types fix. linear_sum_assignment has the correct signature for METH_VARARGS | METH_KEYWORDS: PyCFunctionWithKeywords which is PyObject* (*f)(PyObject*,PyObject*,PyObject*). The ml_meth entry in PyMethodDef must have type PyCFunction which is PyObject* (*f)(PyObject*,PyObject*). To prevent an error, we have to cast it explicitly.

@hoodmane hoodmane requested a review from andyfaff as a code owner August 30, 2022 19:15
@rgommers rgommers changed the title MAINT Cast linear_sum_assignment to PyCFunction MAINT: cast linear_sum_assignment to PyCFunction Aug 31, 2022
@rgommers rgommers added maintenance Items related to regular maintenance tasks scipy.optimize labels Aug 31, 2022
@rgommers rgommers added this to the 1.10.0 milestone Aug 31, 2022
Copy link
Copy Markdown
Member

@rgommers rgommers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @hoodmane

We have -Wno-incompatible-pointer-types set globally (in the top-level meson.build), and that turns off warnings for a superset of the issue you are running into here. https://clang.llvm.org/docs/DiagnosticsReference.html#wincompatible-pointer-types. GCC doesn't have incompatible-function-pointer-types separately, so we can't enable that easily globally. I'll see if I can clean up the non function pointer issues later.

@rgommers rgommers merged commit f48e1d2 into scipy:main Aug 31, 2022
@rgommers rgommers added the backport-candidate This fix should be ported by a maintainer to previous SciPy versions. label Aug 31, 2022
@rgommers
Copy link
Copy Markdown
Member

The other issues seem to be in f2py-generated code, which explains why Pyodide doesn't see those.

@hoodmane
Copy link
Copy Markdown
Contributor Author

hoodmane commented Aug 31, 2022

The other issues seem to be in f2py-generated code, which explains why Pyodide doesn't see those.

Well we have very extensive patching to fix these. But anything that touches fortran can't be easily upstreamed.

@rgommers
Copy link
Copy Markdown
Member

Hmm, I thought that was just the void vs. int return issue, not the use of PyArray_DATA for example (that's the main culprit). I'll have a look at your patches again though.

@hoodmane
Copy link
Copy Markdown
Contributor Author

Good point, I'm not sure. I think we have to fix both because we compile with -Wno-incompatible-pointer-types.

@rgommers
Copy link
Copy Markdown
Member

Follow up to this in gh-16942

hoodmane added a commit to pyodide/pyodide that referenced this pull request Sep 5, 2022
This updates scipy to v1.9.1. This was mercifully easy:

* for now we disable meson
* we dropped `patches/0014-BUG-Fix-signature-of-D_IIR_forback-1-2.patch` since it was upstreamed
* we had to add a patch to put fitpack back into a shape that makes f2c happy
* we need one more `-Wincompatible-function-pointer-types` fix upstream PR: scipy/scipy#16934
@tylerjereddy tylerjereddy modified the milestones: 1.10.0, 1.9.2 Oct 2, 2022
@tylerjereddy tylerjereddy removed the backport-candidate This fix should be ported by a maintainer to previous SciPy versions. label Oct 5, 2022
@hoodmane hoodmane deleted the linear-sum-pycfunction branch November 13, 2022 18:35
ryanking13 pushed a commit to pyodide/pyodide-build that referenced this pull request Jun 10, 2024
This updates scipy to v1.9.1. This was mercifully easy:

* for now we disable meson
* we dropped `patches/0014-BUG-Fix-signature-of-D_IIR_forback-1-2.patch` since it was upstreamed
* we had to add a patch to put fitpack back into a shape that makes f2c happy
* we need one more `-Wincompatible-function-pointer-types` fix upstream PR: scipy/scipy#16934
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Items related to regular maintenance tasks scipy.optimize

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants