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

CI: Add a check that Python.h is included first in any file using Python features. #5

Open
wants to merge 142 commits into
base: main
Choose a base branch
from

Conversation

DWesl
Copy link
Owner

@DWesl DWesl commented Apr 17, 2024

Reference issue

Builds from the script in scipy#20149

What does this implement/fix?

Python extensions require Python.h be included first.
Practically speaking, including other headers first will usually result in the visibility macros being set to other values, such that various macros and functions don't get defined and break things later.
This attempts to catch those errors before they cause problems.

Additional information

The script still doesn't know about Boost::Python. Hopefully that's not actually used.

tuhinsharma121 and others added 18 commits April 21, 2024 08:11
BLD: Accelerate builds should not define `NO_APPEND_FORTRAN`
Based on script from scipy#20149.

Doesn't know about Boost::Python yet.

DEV: Print name of file check_python_h_first is checking

DEV: Add numpy/ndarrayobject.h to list of Python-including headers

One file includes this first.
BLD: Move python-including file earlier in io/_fast_matrix_market/src/_fmm_core.cpp

BLD: Move stdlib header after python-including headers in optimize/_pava/pava_pybind.cpp

BLD:BUG: Move python-including file to top of special/_special_ufuncs.cpp

DEV: Move python-including file earlier in wrap_g77_abi.c

Wasn't actually a problem, but this makes it easier for my script to check.

DEV: Move python including file earlier in wrap_dummy_g77_abi.c

Not actually a problem, but this makes it easier for my script to check.

STY: Remove duplicate headers at start of special/sf_error.cc
Hopefully this reduces false-positives.
It does include python first, and this will note that.
The file including the header should have already included Python.h (and whatever file for the specific constructs, or the compilation would fail everywhere)
This can cause errors if the header has no guard, or just slow things a bit if it does have a guard.

CI: Exclude boost_math and highs from header check.

Entirely too many false positives.

CI: Don't check fast_float

It seems to be a bunch of headers concatenated, which naturally results in many duplicate includes.
Not sure what `re.compile` is doing before the matching that takes as long as the regex
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

Successfully merging this pull request may close these issues.

10 participants