From ff7c29ced9d6290962a74db495c54edec215de51 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/_imagingtk.c | 1 - src/_webp.c | 3 +-- src/decode.c | 4 ---- src/display.c | 3 --- src/encode.c | 5 +---- src/libImaging/codec_fd.c | 1 - src/map.c | 2 -- src/outline.c | 2 -- src/path.c | 3 +-- 14 files changed, 11 insertions(+), 40 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 7d88f7d5c..1201e8db7 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 f152fadbf..63fe0eb2f 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 7f2464124..dea13c47e 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 d4912d4a1..f54ca6cd5 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/_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 dfda7048d..cf6e999b1 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 00ecf555d..801bab0b3 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 fa6c3a51c..63f16547f 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/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 067f42f62..53c1dd8c4 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