From 944ba80af7548773d7b9669b048c9b6890e4aa97 Mon Sep 17 00:00:00 2001 From: David Hoese Date: Sun, 8 Sep 2024 20:47:03 -0500 Subject: [PATCH 01/15] Fix documentation referring to deprecated tostring method --- aggdraw.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aggdraw.cxx b/aggdraw.cxx index 0561ddb..f98a0b1 100644 --- a/aggdraw.cxx +++ b/aggdraw.cxx @@ -1549,7 +1549,7 @@ const char *draw_frombytes_doc = "Copies data from a string buffer to the drawin "Parameters\n" "----------\n" "data : bytes\n" - " A string containing packed image data, compatible with PIL’s tostring method.\n"; + " A string containing packed image data, compatible with PIL’s tobytes method.\n"; static PyObject* draw_frombytes(DrawObject* self, PyObject* args) @@ -2587,7 +2587,7 @@ const char *mod_doc = "Python interface to the Anti-Grain Graphics Drawing libra " >>> p = aggdraw.Pen(\"black\", 0.5)\n" " >>> d.line((0, 0, 500, 500), p)\n" " >>> d.line((0, 500, 500, 0), p)\n" - " >>> s = d.tostring()\n"; + " >>> s = d.tobytes()\n"; #ifdef IS_PY3K static struct PyModuleDef moduledef = { From 6b902a5404c108f86bf21608be2e08e7683c0b66 Mon Sep 17 00:00:00 2001 From: David Hoese Date: Sun, 8 Sep 2024 20:49:02 -0500 Subject: [PATCH 02/15] Remove deprecated test_requires from setup.py --- setup.py | 1 - 1 file changed, 1 deletion(-) diff --git a/setup.py b/setup.py index 0af10ad..72ac817 100644 --- a/setup.py +++ b/setup.py @@ -169,5 +169,4 @@ def _get_freetype_with_pkgconfig(): ) ], python_requires='>=3.9', - tests_require=['pillow', 'pytest'], ) From cc40dc3a6ca164c95ab048ca9ea71fc777b88d6c Mon Sep 17 00:00:00 2001 From: David Hoese Date: Tue, 10 Sep 2024 14:56:29 -0500 Subject: [PATCH 03/15] Update cibuildwheel to fix windows wheel building --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0fa2ddd..20f5f1c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,7 +64,7 @@ jobs: pipx ensurepath - name: Build wheels - uses: pypa/cibuildwheel@v2.16.5 + uses: pypa/cibuildwheel@v2.20.0 env: CIBW_TEST_COMMAND: python {project}/selftest.py CIBW_BEFORE_BUILD_LINUX: yum install -y freetype-devel From 48749baaa03aeb64aad3387f181f3738c7435f92 Mon Sep 17 00:00:00 2001 From: David Hoese Date: Tue, 10 Sep 2024 15:14:27 -0500 Subject: [PATCH 04/15] Remove deprecated macos 11 runner and use only macos 14 --- .github/workflows/ci.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 20f5f1c..9f3c102 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,10 +38,8 @@ jobs: include: - os: windows-2019 cibw_archs: "AMD64 ARM64" - - os: macos-11 - cibw_archs: "x86_64" - os: macos-14 # The macos-14 runner is arm64, while up until macos-13 the runners are x86_64. - cibw_archs: "arm64" + cibw_archs: "x86_64 arm64" - os: "ubuntu-20.04" cibw_archs: "aarch64" - os: "ubuntu-20.04" From 2801e5e1eecd4338807c5d8e9f63b0f2a51b4d28 Mon Sep 17 00:00:00 2001 From: David Hoese Date: Tue, 10 Sep 2024 15:16:58 -0500 Subject: [PATCH 05/15] Add GCC flags to MacOS building to ignore incompatible agg code --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9f3c102..121bb63 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -72,6 +72,8 @@ jobs: CIBW_ARCHS: "${{ matrix.cibw_archs }}" # disable finding unintended freetype installations CIBW_ENVIRONMENT_WINDOWS: "AGGDRAW_FREETYPE_ROOT=''" + # agg is not compatible with GCC 14+ + CIBW_ENVIRONMENT_MACOS: CFLAGS='-fpermissive' - name: upload uses: actions/upload-artifact@v3 with: From 8c5cba4bd5e6ca7bf848048276df458679e7ec13 Mon Sep 17 00:00:00 2001 From: David Hoese Date: Tue, 10 Sep 2024 15:24:51 -0500 Subject: [PATCH 06/15] Use CXXFLAGS instead of CFLAGS in macos CI --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 121bb63..ad322b6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -73,7 +73,7 @@ jobs: # disable finding unintended freetype installations CIBW_ENVIRONMENT_WINDOWS: "AGGDRAW_FREETYPE_ROOT=''" # agg is not compatible with GCC 14+ - CIBW_ENVIRONMENT_MACOS: CFLAGS='-fpermissive' + CIBW_ENVIRONMENT_MACOS: CXXFLAGS='-fpermissive' - name: upload uses: actions/upload-artifact@v3 with: From bbed12487d1aa0ecb42a5bc195eee0593b792910 Mon Sep 17 00:00:00 2001 From: David Hoese Date: Tue, 10 Sep 2024 15:32:49 -0500 Subject: [PATCH 07/15] Use extra_compile_args for working aroung old agg code --- setup.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 72ac817..e3b254a 100644 --- a/setup.py +++ b/setup.py @@ -146,6 +146,9 @@ def _get_freetype_with_pkgconfig(): if sys.platform == "win32": libraries.extend(["kernel32", "user32", "gdi32"]) +# agg C++ is not compatible with gcc 14 +extra_compile_args = ["-fpermissive"] + setup( name="aggdraw", version=VERSION, @@ -165,7 +168,8 @@ def _get_freetype_with_pkgconfig(): Extension("aggdraw", ["aggdraw.cxx"] + sources, define_macros=defines, include_dirs=include_dirs, - library_dirs=library_dirs, libraries=libraries + library_dirs=library_dirs, libraries=libraries, + extra_compile_args=extra_compile_args, ) ], python_requires='>=3.9', From 223ddfe0684be1290c74552eb4bcad69e871e8da Mon Sep 17 00:00:00 2001 From: David Hoese Date: Tue, 10 Sep 2024 15:33:11 -0500 Subject: [PATCH 08/15] Remove custom flags only for cibuildwheel macos --- .github/workflows/ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ad322b6..9f3c102 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -72,8 +72,6 @@ jobs: CIBW_ARCHS: "${{ matrix.cibw_archs }}" # disable finding unintended freetype installations CIBW_ENVIRONMENT_WINDOWS: "AGGDRAW_FREETYPE_ROOT=''" - # agg is not compatible with GCC 14+ - CIBW_ENVIRONMENT_MACOS: CXXFLAGS='-fpermissive' - name: upload uses: actions/upload-artifact@v3 with: From 789c26e9eb2205d9c476026c1a1c70657a26fff4 Mon Sep 17 00:00:00 2001 From: David Hoese Date: Tue, 10 Sep 2024 20:43:46 -0500 Subject: [PATCH 09/15] Add additional compiler flags to fix newer compiler errors --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index e3b254a..a22f66f 100644 --- a/setup.py +++ b/setup.py @@ -147,7 +147,7 @@ def _get_freetype_with_pkgconfig(): libraries.extend(["kernel32", "user32", "gdi32"]) # agg C++ is not compatible with gcc 14 -extra_compile_args = ["-fpermissive"] +extra_compile_args = ["-fpermissive", "-Wno-pointer-sign"] setup( name="aggdraw", From c7d8c51d1f577563bad9cd29cd8feaf799864aeb Mon Sep 17 00:00:00 2001 From: David Hoese Date: Wed, 11 Sep 2024 15:29:01 +0000 Subject: [PATCH 10/15] Add patch for agg pointer type --- README.rst | 11 +++++++++++ agg2/font_freetype/agg_font_freetype.cpp | 2 +- patches/tags_pointer_type_fix.patch | 11 +++++++++++ setup.py | 4 ---- 4 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 patches/tags_pointer_type_fix.patch diff --git a/README.rst b/README.rst index 53f782f..19da976 100644 --- a/README.rst +++ b/README.rst @@ -93,3 +93,14 @@ ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +Additional Patches +------------------ + +The AGG C++ vendored source code in this repository is no longer compatible +with some modern compilers and coding styles. The aggdraw project has had to +apply additional patches over time to fix compatibility or to retain backwards +compatibility with previous versions of AGG to get the same end result. Some +patches may be documented in README files, but all future patches should appear +in the `patches/` directory in the root of this repository and were applied with +commands such as `patch -p0 patches/tags_pointer_type_fix.patch`. diff --git a/agg2/font_freetype/agg_font_freetype.cpp b/agg2/font_freetype/agg_font_freetype.cpp index 0af06f6..8218d15 100644 --- a/agg2/font_freetype/agg_font_freetype.cpp +++ b/agg2/font_freetype/agg_font_freetype.cpp @@ -150,7 +150,7 @@ namespace agg FT_Vector* point; FT_Vector* limit; - char* tags; + unsigned char* tags; int n; // index of contour in outline int first; // index of first point in contour diff --git a/patches/tags_pointer_type_fix.patch b/patches/tags_pointer_type_fix.patch new file mode 100644 index 0000000..14d85a6 --- /dev/null +++ b/patches/tags_pointer_type_fix.patch @@ -0,0 +1,11 @@ +--- agg2/font_freetype/agg_font_freetype.cpp.orig 2024-03-06 10:16:58 ++++ agg2/font_freetype/agg_font_freetype.cpp 2024-09-11 09:17:23 +@@ -150,7 +150,7 @@ + + FT_Vector* point; + FT_Vector* limit; +- char* tags; ++ unsigned char* tags; + + int n; // index of contour in outline + int first; // index of first point in contour diff --git a/setup.py b/setup.py index a22f66f..67c261a 100644 --- a/setup.py +++ b/setup.py @@ -146,9 +146,6 @@ def _get_freetype_with_pkgconfig(): if sys.platform == "win32": libraries.extend(["kernel32", "user32", "gdi32"]) -# agg C++ is not compatible with gcc 14 -extra_compile_args = ["-fpermissive", "-Wno-pointer-sign"] - setup( name="aggdraw", version=VERSION, @@ -169,7 +166,6 @@ def _get_freetype_with_pkgconfig(): define_macros=defines, include_dirs=include_dirs, library_dirs=library_dirs, libraries=libraries, - extra_compile_args=extra_compile_args, ) ], python_requires='>=3.9', From bd41e52327ae8afc9ed9bb5f928a013d7bfdc340 Mon Sep 17 00:00:00 2001 From: David Hoese Date: Wed, 11 Sep 2024 15:39:26 +0000 Subject: [PATCH 11/15] Switch to casting patch for tags pointer --- agg2/font_freetype/agg_font_freetype.cpp | 4 ++-- patches/tags_pointer_type_fix.patch | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/agg2/font_freetype/agg_font_freetype.cpp b/agg2/font_freetype/agg_font_freetype.cpp index 8218d15..ce95a38 100644 --- a/agg2/font_freetype/agg_font_freetype.cpp +++ b/agg2/font_freetype/agg_font_freetype.cpp @@ -150,7 +150,7 @@ namespace agg FT_Vector* point; FT_Vector* limit; - unsigned char* tags; + char* tags; int n; // index of contour in outline int first; // index of first point in contour @@ -171,7 +171,7 @@ namespace agg v_control = v_start; point = outline.points + first; - tags = outline.tags + first; + tags = (char *)outline.tags + first; tag = FT_CURVE_TAG(tags[0]); // A contour cannot start with a cubic control point! diff --git a/patches/tags_pointer_type_fix.patch b/patches/tags_pointer_type_fix.patch index 14d85a6..ad4173a 100644 --- a/patches/tags_pointer_type_fix.patch +++ b/patches/tags_pointer_type_fix.patch @@ -1,11 +1,11 @@ --- agg2/font_freetype/agg_font_freetype.cpp.orig 2024-03-06 10:16:58 -+++ agg2/font_freetype/agg_font_freetype.cpp 2024-09-11 09:17:23 -@@ -150,7 +150,7 @@ ++++ agg2/font_freetype/agg_font_freetype.cpp 2024-09-10 21:13:37 +@@ -171,7 +171,7 @@ + v_control = v_start; - FT_Vector* point; - FT_Vector* limit; -- char* tags; -+ unsigned char* tags; + point = outline.points + first; +- tags = outline.tags + first; ++ tags = (char *)outline.tags + first; + tag = FT_CURVE_TAG(tags[0]); - int n; // index of contour in outline - int first; // index of first point in contour + // A contour cannot start with a cubic control point! From 2aadd4c430200bd101fba516d6bbc0ef0aeae233 Mon Sep 17 00:00:00 2001 From: David Hoese Date: Wed, 11 Sep 2024 15:52:41 +0000 Subject: [PATCH 12/15] Use macos 13 for x86 wheel builds --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9f3c102..62bcc6c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,8 +38,10 @@ jobs: include: - os: windows-2019 cibw_archs: "AMD64 ARM64" + - os: macos-13 + cibw_archs: "x86_64" - os: macos-14 # The macos-14 runner is arm64, while up until macos-13 the runners are x86_64. - cibw_archs: "x86_64 arm64" + cibw_archs: "arm64" - os: "ubuntu-20.04" cibw_archs: "aarch64" - os: "ubuntu-20.04" From 83241556f7aca46ce396f3d67877048236db6d72 Mon Sep 17 00:00:00 2001 From: David Hoese Date: Wed, 11 Sep 2024 15:56:46 +0000 Subject: [PATCH 13/15] Force macos build target to 12 --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 62bcc6c..d3396bc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -74,6 +74,9 @@ jobs: CIBW_ARCHS: "${{ matrix.cibw_archs }}" # disable finding unintended freetype installations CIBW_ENVIRONMENT_WINDOWS: "AGGDRAW_FREETYPE_ROOT=''" + # we use libpng/libfreetype from homebrew which has a current limit of + # macos 12 (Monterey): https://formulae.brew.sh/formula/libomp + CIBW_ENVIRONMENT_MACOS: MACOSX_DEPLOYMENT_TARGET=12 - name: upload uses: actions/upload-artifact@v3 with: From cea58f4377d67a080f4d03ded442d0cc23c7c7c1 Mon Sep 17 00:00:00 2001 From: David Hoese Date: Wed, 11 Sep 2024 16:01:24 +0000 Subject: [PATCH 14/15] Bump macos target to 14 --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d3396bc..52c84b2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -75,8 +75,8 @@ jobs: # disable finding unintended freetype installations CIBW_ENVIRONMENT_WINDOWS: "AGGDRAW_FREETYPE_ROOT=''" # we use libpng/libfreetype from homebrew which has a current limit of - # macos 12 (Monterey): https://formulae.brew.sh/formula/libomp - CIBW_ENVIRONMENT_MACOS: MACOSX_DEPLOYMENT_TARGET=12 + # macos 14 + CIBW_ENVIRONMENT_MACOS: MACOSX_DEPLOYMENT_TARGET=14 - name: upload uses: actions/upload-artifact@v3 with: From 8eba0c12fa6d0b4fc94991dfa0d7c481fbeae3dd Mon Sep 17 00:00:00 2001 From: David Hoese Date: Wed, 11 Sep 2024 16:06:38 +0000 Subject: [PATCH 15/15] Switch to newer miniconda action and remove x86 mac builds --- .github/workflows/ci.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 52c84b2..b8dd126 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,14 +14,14 @@ jobs: - uses: actions/checkout@v4 - name: Setup Conda Environment - uses: conda-incubator/setup-miniconda@v2 + uses: conda-incubator/setup-miniconda@v3 with: - miniforge-variant: Mambaforge miniforge-version: latest - use-mamba: true python-version: ${{ matrix.python-version }} environment-file: ci/environment.yaml activate-environment: test-environment + mamba-version: "*" + channels: conda-forge - name: Run tests shell: bash -l {0} @@ -38,8 +38,6 @@ jobs: include: - os: windows-2019 cibw_archs: "AMD64 ARM64" - - os: macos-13 - cibw_archs: "x86_64" - os: macos-14 # The macos-14 runner is arm64, while up until macos-13 the runners are x86_64. cibw_archs: "arm64" - os: "ubuntu-20.04"