8000 BLD,Cygwin: Include Python.h first in various C++ files by DWesl · Pull Request #27821 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

BLD,Cygwin: Include Python.h first in various C++ files #27821

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

Merged
merged 12 commits into from
Mar 7, 2024

Conversation

DWesl
Copy link
Contributor
@DWesl DWesl commented Feb 25, 2024

PR summary

Python.h needs to be included before any system includes. This is easiest if it is the first include.

EDIT: pybind11/pybind11.h includes Python three headers in. There are two system headers included beforehand, if debugging with MSVC. I didn't know that when I made this, and can remove Python.h from before pybind11/pybind11.h if desired.

Should fix the Cygwin problem noted in #27552

PR checklist

Python.h needs to be included before any system includes.  This is easiest if it is the first include.  Interestingly, pybind11/pybind11.h does not include Python, possibly depending on downstream projects including Python.h beforehand.
@ksunden ksunden added the CI: Run cygwin Run cygwin tests on a PR label Feb 25, 2024
Needs to be included before system headers to set visibility macros for pybind11
@github-actions github-actions bot added GUI: tk and removed CI: Run cygwin Run cygwin tests on a PR labels Feb 25, 2024
pybind11 assumes Python.h is included first.
@DWesl
Copy link
Contributor Author
DWesl commented Feb 25, 2024

Checked all files instead of going one-by-one using check_python_h_first.py adapted from scipy/scipy#18049.

8000

@github-actions github-actions bot added the CI: Run cygwin Run cygwin tests on a PR label Feb 25, 2024
Cygwin pytest recently updated, and only installs pytest-3.9
@DWesl DWesl changed the title BLD,Cygwin: Include Python.h first in src/_c_internal_utils.cpp BLD,Cygwin: Include Python.h first in various C++ files Feb 25, 2024
@tacaswell tacaswell added this to the v3.9.0 milestone Feb 26, 2024
@QuLogic
Copy link
Member
QuLogic commented Mar 6, 2024

I think we should just consider pybind11.h to be like Python.h and ensure it is first (and so drop the extra Python.h additions if possible.)

Copy link
Contributor Author
@DWesl DWesl left a comment

Choose a reason for hiding this comment

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

Remove Python.h includes immediately preceeding pybind11/pybind11.h includes.

…ind11.h includes


pybind11 seems decent about including Python.h before any system headers, once you chase three layers of includes in to see that.
@QuLogic QuLogic mentioned this pull request Mar 6, 2024
1 task
@ksunden ksunden merged commit efcca8d into matplotlib:main Mar 7, 2024
@DWesl DWesl deleted the patch-5 branch March 8, 2024 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0