From 052e4e704ce0a147f862f67536d679f17f6f5e62 Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Sat, 24 Feb 2024 21:47:20 -0500 Subject: [PATCH 01/12] BLD,Cygwin: Included Python.h first in src/_c_internal_utils.cpp 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. --- src/_c_internal_utils.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/_c_internal_utils.cpp b/src/_c_internal_utils.cpp index 813aeb6f7d5a..464aabcb2e3a 100644 --- a/src/_c_internal_utils.cpp +++ b/src/_c_internal_utils.cpp @@ -1,3 +1,6 @@ +#include +/* Python.h must be included before any system headers, + to ensure visibility macros are properly set. */ #include #ifdef _WIN32 From 454225ac98eb051041c9b30e2fb7c9a118baf89e Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Sun, 25 Feb 2024 06:34:33 -0500 Subject: [PATCH 02/12] CI: Include Python.h first in _tkagg.cpp Needs to be included before system headers to set visibility macros for pybind11 --- src/_tkagg.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/_tkagg.cpp b/src/_tkagg.cpp index 3b58114a71c0..91cf285202ed 100644 --- a/src/_tkagg.cpp +++ b/src/_tkagg.cpp @@ -9,6 +9,7 @@ // rewritten, we have removed the PIL licensing information. If you want PIL, // you can get it at https://python-pillow.org/ +#include #include #include #include From c0f19daa075d057450eac70c7bccea094e2da18f Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Sun, 25 Feb 2024 06:37:00 -0500 Subject: [PATCH 03/12] BLD: Include Python.h first in _backend_agg.cpp --- src/_backend_agg.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/_backend_agg.cpp b/src/_backend_agg.cpp index 10a17f2dc9cb..c35f92eb8fc1 100644 --- a/src/_backend_agg.cpp +++ b/src/_backend_agg.cpp @@ -2,6 +2,7 @@ #define NO_IMPORT_ARRAY +#include #include "_backend_agg.h" #include "mplutils.h" From 25deb90a73145aae6fb8437389af9c415dead516 Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Sun, 25 Feb 2024 07:21:21 -0500 Subject: [PATCH 04/12] BLD: Include Python.h before pybind11/pybind11.h pybind11 assumes Python.h is included first. --- src/_image_wrapper.cpp | 1 + src/_qhull_wrapper.cpp | 1 + src/_ttconv.cpp | 1 + src/ft2font.h | 8 +++++--- src/numpy_cpp.h | 8 ++++---- src/py_converters_11.h | 1 + src/tri/_tri.h | 1 + 7 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/_image_wrapper.cpp b/src/_image_wrapper.cpp index 716116c0ba56..c40e3d5c8d67 100644 --- a/src/_image_wrapper.cpp +++ b/src/_image_wrapper.cpp @@ -1,3 +1,4 @@ +#include #include #include diff --git a/src/_qhull_wrapper.cpp b/src/_qhull_wrapper.cpp index 9784a1698ba1..cae9aca959ee 100644 --- a/src/_qhull_wrapper.cpp +++ b/src/_qhull_wrapper.cpp @@ -5,6 +5,7 @@ * triangulation, construct an instance of the matplotlib.tri.Triangulation * class without specifying a triangles array. */ +#include #include #include diff --git a/src/_ttconv.cpp b/src/_ttconv.cpp index a682c26b17b0..559d898886cd 100644 --- a/src/_ttconv.cpp +++ b/src/_ttconv.cpp @@ -5,6 +5,7 @@ Python wrapper for TrueType conversion library in ../ttconv. */ +#include #include "mplutils.h" #include diff --git a/src/ft2font.h b/src/ft2font.h index 69dafb66bdca..6b8f05466700 100644 --- a/src/ft2font.h +++ b/src/ft2font.h @@ -2,8 +2,13 @@ /* A python interface to FreeType */ #pragma once + #ifndef MPL_FT2FONT_H #define MPL_FT2FONT_H + +#define PY_SSIZE_T_CLEAN +#include + #include #include #include @@ -19,9 +24,6 @@ extern "C" { #include FT_TRUETYPE_TABLES_H } -#define PY_SSIZE_T_CLEAN -#include - /* By definition, FT_FIXED as 2 16bit values stored in a single long. */ diff --git a/src/numpy_cpp.h b/src/numpy_cpp.h index a69c1cb29a50..6165789b7603 100644 --- a/src/numpy_cpp.h +++ b/src/numpy_cpp.h @@ -14,10 +14,6 @@ * original. */ -#include "py_exceptions.h" - -#include - #ifdef _POSIX_C_SOURCE # undef _POSIX_C_SOURCE #endif @@ -40,6 +36,10 @@ #include #include +#include "py_exceptions.h" + +#include + namespace numpy { diff --git a/src/py_converters_11.h b/src/py_converters_11.h index 9af617d3ee8b..ceef9ee542d1 100644 --- a/src/py_converters_11.h +++ b/src/py_converters_11.h @@ -3,6 +3,7 @@ // pybind11 equivalent of py_converters.h +#include #include #include diff --git a/src/tri/_tri.h b/src/tri/_tri.h index c176b4c0e8f5..d7d2b4ebf413 100644 --- a/src/tri/_tri.h +++ b/src/tri/_tri.h @@ -63,6 +63,7 @@ #ifndef MPL_TRI_H #define MPL_TRI_H +#include #include #include From 59a2d1a7bde6c3d2a9ec50470094e124083399b8 Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Sun, 25 Feb 2024 08:16:11 -0500 Subject: [PATCH 05/12] CI: Specify python version for default pytest. --- .github/workflows/cygwin.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cygwin.yml b/.github/workflows/cygwin.yml index 97c8c34afa60..4a8edf40d49e 100644 --- a/.github/workflows/cygwin.yml +++ b/.github/workflows/cygwin.yml @@ -168,6 +168,7 @@ jobs: run: | /usr/sbin/alternatives --set python /usr/bin/python3.${{ matrix.python-minor-version }} /usr/sbin/alternatives --set python3 /usr/bin/python3.${{ matrix.python-minor-version }} + /usr/sbin/alternatives --set pytest /usr/bin/pytest-3.${{matrix.python-minor-version }} - name: Install Python dependencies shell: bash.exe -eo pipefail -o igncr "{0}" From 242ddfcc997e4449fec818b552fdf741765bcc7c Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Sun, 25 Feb 2024 12:02:49 -0500 Subject: [PATCH 06/12] CI,Cygwin: Run pytest with python -m pytest Cygwin pytest recently updated, and only installs pytest-3.9 --- .github/workflows/cygwin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cygwin.yml b/.github/workflows/cygwin.yml index 4a8edf40d49e..94395edf4088 100644 --- a/.github/workflows/cygwin.yml +++ b/.github/workflows/cygwin.yml @@ -244,7 +244,7 @@ jobs: shell: bash.exe -eo pipefail -o igncr "{0}" id: cygwin-run-pytest run: | - xvfb-run pytest -rfEsXR -n auto \ + xvfb-run python -m pytest -rfEsXR -n auto \ --maxfail=50 --timeout=300 --durations=25 \ --cov-report=xml --cov=lib --log-level=DEBUG --color=yes From 39e303ed734033e87eefba72f5ff9ba866c48234 Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Sun, 25 Feb 2024 12:19:56 -0500 Subject: [PATCH 07/12] CI,Cygwin: Revert use of alternatives to set pytest script. Cygwin pytest only installs pytest-3.9. I should possibly suggest using alternatives for that and pip. --- .github/workflows/cygwin.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/cygwin.yml b/.github/workflows/cygwin.yml index 94395edf4088..2fe94550dc4b 100644 --- a/.github/workflows/cygwin.yml +++ b/.github/workflows/cygwin.yml @@ -168,7 +168,6 @@ jobs: run: | /usr/sbin/alternatives --set python /usr/bin/python3.${{ matrix.python-minor-version }} /usr/sbin/alternatives --set python3 /usr/bin/python3.${{ matrix.python-minor-version }} - /usr/sbin/alternatives --set pytest /usr/bin/pytest-3.${{matrix.python-minor-version }} - name: Install Python dependencies shell: bash.exe -eo pipefail -o igncr "{0}" From 8eb9f475d60b82e6da3ebb08f0c5d5b943bf0de7 Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Sun, 25 Feb 2024 13:07:52 -0500 Subject: [PATCH 08/12] CI,Cygwin: Avoid running pytest in root directory. --- .github/workflows/cygwin.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/cygwin.yml b/.github/workflows/cygwin.yml index 2fe94550dc4b..efcfcc70db1f 100644 --- a/.github/workflows/cygwin.yml +++ b/.github/workflows/cygwin.yml @@ -243,6 +243,8 @@ jobs: shell: bash.exe -eo pipefail -o igncr "{0}" id: cygwin-run-pytest run: | + mkdir run-test + cd run-test xvfb-run python -m pytest -rfEsXR -n auto \ --maxfail=50 --timeout=300 --durations=25 \ --cov-report=xml --cov=lib --log-level=DEBUG --color=yes From 1b81830ec629064b65d9035ec92bd4d503f90b26 Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Sun, 25 Feb 2024 16:30:20 -0500 Subject: [PATCH 09/12] CI,Cygwin: Revert running pytest in different directory. --- .github/workflows/cygwin.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/cygwin.yml b/.github/workflows/cygwin.yml index efcfcc70db1f..2fe94550dc4b 100644 --- a/.github/workflows/cygwin.yml +++ b/.github/workflows/cygwin.yml @@ -243,8 +243,6 @@ jobs: shell: bash.exe -eo pipefail -o igncr "{0}" id: cygwin-run-pytest run: | - mkdir run-test - cd run-test xvfb-run python -m pytest -rfEsXR -n auto \ --maxfail=50 --timeout=300 --durations=25 \ --cov-report=xml --cov=lib --log-level=DEBUG --color=yes From 4b131a14d90bfc2453ad0f43fa1174eedd7205c7 Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Sun, 25 Feb 2024 18:44:01 -0500 Subject: [PATCH 10/12] CI,Cygwin: Call pytest-3.9 explicitly. --- .github/workflows/cygwin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cygwin.yml b/.github/workflows/cygwin.yml index 2fe94550dc4b..3e2a6144dece 100644 --- a/.github/workflows/cygwin.yml +++ b/.github/workflows/cygwin.yml @@ -243,7 +243,7 @@ jobs: shell: bash.exe -eo pipefail -o igncr "{0}" id: cygwin-run-pytest run: | - xvfb-run python -m pytest -rfEsXR -n auto \ + xvfb-run pytest-3.${{ matrix.python-minor-version }} -rfEsXR -n auto \ --maxfail=50 --timeout=300 --durations=25 \ --cov-report=xml --cov=lib --log-level=DEBUG --color=yes From bdfc4ce7ba0e9f794590599966f6511f1d771a26 Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Sun, 25 Feb 2024 21:04:10 -0500 Subject: [PATCH 11/12] BLD: Include Python.h first in src/_path.h --- src/_path.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/_path.h b/src/_path.h index 239a3c760221..d45842df4cac 100644 --- a/src/_path.h +++ b/src/_path.h @@ -3,6 +3,7 @@ #ifndef MPL_PATH_H #define MPL_PATH_H +#include #include #include #include From 66149edad6dcec0a02f6347f855f09a3dbd4f17a Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Wed, 6 Mar 2024 10:29:31 -0500 Subject: [PATCH 12/12] BLD,BUG: Remove Python.h includes immediately preceeding pybind11/pybind11.h includes pybind11 seems decent about including Python.h before any system headers, once you chase three layers of includes in to see that. --- src/_image_wrapper.cpp | 1 - src/_path.h | 1 - src/_qhull_wrapper.cpp | 1 - src/_ttconv.cpp | 4 +--- src/py_converters_11.h | 1 - src/tri/_tri.h | 1 - 6 files changed, 1 insertion(+), 8 deletions(-) diff --git a/src/_image_wrapper.cpp b/src/_image_wrapper.cpp index c40e3d5c8d67..716116c0ba56 100644 --- a/src/_image_wrapper.cpp +++ b/src/_image_wrapper.cpp @@ -1,4 +1,3 @@ -#include #include #include diff --git a/src/_path.h b/src/_path.h index d45842df4cac..239a3c760221 100644 --- a/src/_path.h +++ b/src/_path.h @@ -3,7 +3,6 @@ #ifndef MPL_PATH_H #define MPL_PATH_H -#include #include #include #include diff --git a/src/_qhull_wrapper.cpp b/src/_qhull_wrapper.cpp index cae9aca959ee..9784a1698ba1 100644 --- a/src/_qhull_wrapper.cpp +++ b/src/_qhull_wrapper.cpp @@ -5,7 +5,6 @@ * triangulation, construct an instance of the matplotlib.tri.Triangulation * class without specifying a triangles array. */ -#include #include #include diff --git a/src/_ttconv.cpp b/src/_ttconv.cpp index 559d898886cd..715d46d4cf7a 100644 --- a/src/_ttconv.cpp +++ b/src/_ttconv.cpp @@ -5,10 +5,8 @@ Python wrapper for TrueType conversion library in ../ttconv. */ -#include -#include "mplutils.h" - #include +#include "mplutils.h" #include "pprdrv.h" #include diff --git a/src/py_converters_11.h b/src/py_converters_11.h index ceef9ee542d1..9af617d3ee8b 100644 --- a/src/py_converters_11.h +++ b/src/py_converters_11.h @@ -3,7 +3,6 @@ // pybind11 equivalent of py_converters.h -#include #include #include diff --git a/src/tri/_tri.h b/src/tri/_tri.h index d7d2b4ebf413..c176b4c0e8f5 100644 --- a/src/tri/_tri.h +++ b/src/tri/_tri.h @@ -63,7 +63,6 @@ #ifndef MPL_TRI_H #define MPL_TRI_H -#include #include #include