From 81ce71e0ec40086a1509f2332690466ae61383e9 Mon Sep 17 00:00:00 2001 From: Aleksandr Karpinskii Date: Sun, 1 Sep 2024 21:09:14 +0400 Subject: [PATCH] Move include Python.h to ImagingPlatform --- Tests/test_image_access.py | 2 +- src/_imaging.c | 3 --- src/_imagingcms.c | 12 ++++-------- src/_imagingft.c | 4 +--- src/_imagingmath.c | 6 ++---- src/_imagingmorph.c | 1 - src/_imagingtk.c | 1 - src/_webp.c | 3 +-- src/decode.c | 4 ---- src/display.c | 3 --- src/encode.c | 5 +---- src/libImaging/ImagingPlatform.h | 1 + src/libImaging/codec_fd.c | 1 - src/map.c | 2 -- src/outline.c | 2 -- src/path.c | 3 +-- 16 files changed, 12 insertions(+), 41 deletions(-) diff --git a/Tests/test_image_access.py b/Tests/test_image_access.py index bb30b462d..4e3435cfe 100644 --- a/Tests/test_image_access.py +++ b/Tests/test_image_access.py @@ -282,7 +282,7 @@ class TestEmbeddable: home = sys.prefix.replace("\\", "\\\\") fh.write( f""" -#include "Python.h" +#include int main(int argc, char* argv[]) {{ diff --git a/src/_imaging.c b/src/_imaging.c index 07d9a64cc..04ed5545c 100644 --- a/src/_imaging.c +++ b/src/_imaging.c @@ -71,9 +71,6 @@ * See the README file for information on usage and redistribution. */ -#define PY_SSIZE_T_CLEAN -#include "Python.h" - #ifdef HAVE_LIBJPEG #include "jconfig.h" #endif diff --git a/src/_imagingcms.c b/src/_imagingcms.c index 225bb2158..8103b3d5e 100644 --- a/src/_imagingcms.c +++ b/src/_imagingcms.c @@ -26,15 +26,11 @@ kevin@cazabon.com\n\ https://www.cazabon.com\n\ " -#define PY_SSIZE_T_CLEAN -#include "Python.h" // Include before wchar.h so _GNU_SOURCE is set -#include "wchar.h" -#include "datetime.h" +#include "libImaging/Imaging.h" // Include before wchar.h so _GNU_SOURCE is set -#include "lcms2.h" -#include "libImaging/Imaging.h" - -#define PYCMSVERSION "1.0.0 pil" +#include +#include +#include /* version history */ diff --git a/src/_imagingft.c b/src/_imagingft.c index f8143e0cc..6f94c906a 100644 --- a/src/_imagingft.c +++ b/src/_imagingft.c @@ -18,10 +18,8 @@ * Copyright (c) 1998-2007 by Secret Labs AB */ -#define PY_SSIZE_T_CLEAN -#include "Python.h" -#include "thirdparty/pythoncapi_compat.h" #include "libImaging/Imaging.h" +#include "thirdparty/pythoncapi_compat.h" #include #include FT_FREETYPE_H diff --git a/src/_imagingmath.c b/src/_imagingmath.c index 550a10903..bfbd648b4 100644 --- a/src/_imagingmath.c +++ b/src/_imagingmath.c @@ -13,12 +13,10 @@ * See the README file for information on usage and redistribution. */ -#include "Python.h" - #include "libImaging/Imaging.h" -#include "math.h" -#include "float.h" +#include +#include #define MAX_INT32 2147483647.0 #define MIN_INT32 -2147483648.0 diff --git a/src/_imagingmorph.c b/src/_imagingmorph.c index 614dfbe7f..c7548b4e9 100644 --- a/src/_imagingmorph.c +++ b/src/_imagingmorph.c @@ -11,7 +11,6 @@ * See the README file for information on usage and redistribution. */ -#include "Python.h" #include "libImaging/Imaging.h" #define LUT_SIZE (1 << 9) diff --git a/src/_imagingtk.c b/src/_imagingtk.c index c70d044bb..076995daf 100644 --- a/src/_imagingtk.c +++ b/src/_imagingtk.c @@ -12,7 +12,6 @@ * See the README file for information on usage and redistribution. */ -#include "Python.h" #include "libImaging/Imaging.h" #include "Tk/_tkmini.h" diff --git a/src/_webp.c b/src/_webp.c index f59ad3036..9e66cdb8c 100644 --- a/src/_webp.c +++ b/src/_webp.c @@ -1,6 +1,5 @@ -#define PY_SSIZE_T_CLEAN -#include #include "libImaging/Imaging.h" + #include #include #include diff --git a/src/decode.c b/src/decode.c index 51d0aced2..d002f0649 100644 --- a/src/decode.c +++ b/src/decode.c @@ -29,11 +29,7 @@ /* FIXME: make these pluggable! */ -#define PY_SSIZE_T_CLEAN -#include "Python.h" - #include "libImaging/Imaging.h" - #include "libImaging/Bit.h" #include "libImaging/Bcn.h" #include "libImaging/Gif.h" diff --git a/src/display.c b/src/display.c index f6380dff3..078016797 100644 --- a/src/display.c +++ b/src/display.c @@ -22,9 +22,6 @@ * See the README file for information on usage and redistribution. */ -#define PY_SSIZE_T_CLEAN -#include "Python.h" - #include "libImaging/Imaging.h" /* -------------------------------------------------------------------- */ diff --git a/src/encode.c b/src/encode.c index 1a4cd489d..f828401b6 100644 --- a/src/encode.c +++ b/src/encode.c @@ -22,11 +22,8 @@ /* FIXME: make these pluggable! */ -#define PY_SSIZE_T_CLEAN -#include "Python.h" - -#include "thirdparty/pythoncapi_compat.h" #include "libImaging/Imaging.h" +#include "thirdparty/pythoncapi_compat.h" #include "libImaging/Gif.h" #ifdef HAVE_UNISTD_H diff --git a/src/libImaging/ImagingPlatform.h b/src/libImaging/ImagingPlatform.h index e28415d5b..78d27067c 100644 --- a/src/libImaging/ImagingPlatform.h +++ b/src/libImaging/ImagingPlatform.h @@ -7,6 +7,7 @@ * Copyright (c) Fredrik Lundh 1995-2003. */ +#define PY_SSIZE_T_CLEAN #include /* Check that we have an ANSI compliant compiler */ diff --git a/src/libImaging/codec_fd.c b/src/libImaging/codec_fd.c index 526168110..f5541c332 100644 --- a/src/libImaging/codec_fd.c +++ b/src/libImaging/codec_fd.c @@ -1,4 +1,3 @@ -#include "Python.h" #include "Imaging.h" Py_ssize_t diff --git a/src/map.c b/src/map.c index c66702981..2fcaa74d2 100644 --- a/src/map.c +++ b/src/map.c @@ -18,8 +18,6 @@ * FIXME: should move the memory mapping primitives into libImaging! */ -#include "Python.h" - #include "libImaging/Imaging.h" /* compatibility wrappers (defined in _imaging.c) */ diff --git a/src/outline.c b/src/outline.c index 27cc255cf..b84bef437 100644 --- a/src/outline.c +++ b/src/outline.c @@ -17,8 +17,6 @@ * See the README file for information on usage and redistribution. */ -#include "Python.h" - #include "libImaging/Imaging.h" /* -------------------------------------------------------------------- */ diff --git a/src/path.c b/src/path.c index b96e8b78a..78a4f09f5 100644 --- a/src/path.c +++ b/src/path.c @@ -25,9 +25,8 @@ * See the README file for information on usage and redistribution. */ -#include "Python.h" -#include "thirdparty/pythoncapi_compat.h" #include "libImaging/Imaging.h" +#include "thirdparty/pythoncapi_compat.h" #include