diff --git a/.github/workflows/test-with-pip.yml b/.github/workflows/test-with-pip.yml index 433c4fb96..cd41027e9 100644 --- a/.github/workflows/test-with-pip.yml +++ b/.github/workflows/test-with-pip.yml @@ -12,8 +12,8 @@ jobs: test-ets: strategy: matrix: - os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] - toolkit: ['null', 'pyside2', 'pyside6', 'pyqt5', 'wx'] + os: ['ubuntu-latest'] # 'macos-latest', 'windows-latest'] + toolkit: ['null'] #, 'pyside2', 'pyside6', 'pyqt5', 'wx'] python-version: ['3.8', '3.10', '3.11'] exclude: # No Wx wheels available for Python 3.11 @@ -30,6 +30,9 @@ jobs: toolkit: 'wx' - os: 'macos-latest' toolkit: 'wx' + # No PySide2 wheels for macos-latest + - os: 'macos-latest' + toolkit: 'pyside2' # Kiva tests hanging on windows, see #1038 - os: 'windows-latest' toolkit: 'pyqt5' diff --git a/kiva/_cython_speedups.pyx b/kiva/_cython_speedups.pyx index dc346dc76..7ee29b170 100644 --- a/kiva/_cython_speedups.pyx +++ b/kiva/_cython_speedups.pyx @@ -8,9 +8,12 @@ # # Thanks for using Enthought open source! import numpy as np -from numpy cimport uint8_t -cimport _hit_test +from numpy cimport uint8_t, import_array +cimport cython +from . cimport _hit_test + +import_array() def points_in_polygon(pts, poly_pts, use_winding=False): """Test whether point pairs in pts are within the polygon, poly_pts. diff --git a/kiva/_marker_renderer.pyx b/kiva/_marker_renderer.pyx index 62a3f35b1..6e3640782 100644 --- a/kiva/_marker_renderer.pyx +++ b/kiva/_marker_renderer.pyx @@ -7,11 +7,13 @@ # is also available online at http://www.enthought.com/licenses/BSD.txt # # Thanks for using Enthought open source! -import cython import numpy as np -from numpy cimport uint8_t -cimport _marker_renderer +from numpy cimport uint8_t, import_array +cimport cython +from . cimport _marker_renderer + +import_array() ctypedef _marker_renderer.marker_renderer_base renderer_base_t diff --git a/kiva/agg/src/osx/plat_support.i b/kiva/agg/src/osx/plat_support.i index cd62243d6..378eca539 100644 --- a/kiva/agg/src/osx/plat_support.i +++ b/kiva/agg/src/osx/plat_support.i @@ -63,7 +63,8 @@ namespace agg24 end_of_pix_formats }; - %name(PixelMap) class pixel_map + %rename(PixelMap) pixel_map; + class pixel_map { public: ~pixel_map(); diff --git a/kiva/compatibility.py b/kiva/compatibility.py new file mode 100644 index 000000000..107fcc76e --- /dev/null +++ b/kiva/compatibility.py @@ -0,0 +1,20 @@ +# (C) Copyright 2025 Enthought, Inc., Austin, TX +# All rights reserved. +# +# This software is provided without warranty under the terms of the BSD +# license included in LICENSE.txt and may be redistributed only under +# the conditions described in the aforementioned license. The license +# is also available online at http://www.enthought.com/licenses/BSD.txt +# +# Thanks for using Enthought open source! +""" Compatibility workaround module + +Module to workaround compatibility issues with different versions of +the enable dependencies. + +""" + +try: + from numpy import sometrue +except ImportError: + from numpy import any as sometrue diff --git a/kiva/line_state.py b/kiva/line_state.py index e8064d888..ec84d9e5d 100644 --- a/kiva/line_state.py +++ b/kiva/line_state.py @@ -1,4 +1,4 @@ -# (C) Copyright 2005-2023 Enthought, Inc., Austin, TX +# (C) Copyright 2005-2025 Enthought, Inc., Austin, TX # All rights reserved. # # This software is provided without warranty under the terms of the BSD @@ -14,8 +14,9 @@ state (eg. Wx, SVG and PDF backends, but not Agg or QPainter). """ -from numpy import array, asarray, shape, sometrue +from numpy import array, asarray, shape +from .compatibility import sometrue from .constants import NO_DASH diff --git a/kiva/quartz/ABCGI.pyx b/kiva/quartz/ABCGI.pyx index 25ac9c1d4..08a22112c 100644 --- a/kiva/quartz/ABCGI.pyx +++ b/kiva/quartz/ABCGI.pyx @@ -19,7 +19,7 @@ cimport numpy import os import warnings -from CTFont import default_font_info +from .CTFont import default_font_info cdef extern from "math.h": double sqrt(double arg) @@ -1479,7 +1479,7 @@ cdef class CGBitmapContext(CGContext): raise ValueError("bits_per_component must be 5 or 8") cdef int min_bytes - min_bytes = (width*bits_per_pixel + 7) / 8 + min_bytes = (width*bits_per_pixel + 7) // 8 if bytes_per_row < min_bytes: bytes_per_row = min_bytes @@ -1763,7 +1763,7 @@ cdef class CGImage: raise ValueError("bits_per_component must be 5 or 8") cdef int min_bytes - min_bytes = (width*bits_per_pixel + 7) / 8 + min_bytes = (width*bits_per_pixel + 7) // 8 if bytes_per_row < min_bytes: bytes_per_row = min_bytes @@ -1826,16 +1826,16 @@ cdef class CGImageFile(CGImage): bits_per_pixel = 8 alpha_info = kCGImageAlphaNone - bytes_per_row = (bits_per_pixel*width + 7)/ 8 + bytes_per_row = (bits_per_pixel*width + 7) // 8 cdef char* data cdef char* py_data - cdef int dims[3] + cdef numpy.npy_intp dims[3] dims[0] = height dims[1] = width - dims[2] = bits_per_pixel/bits_per_component + dims[2] = bits_per_pixel // bits_per_component - self.bmp_array = numpy.PyArray_SimpleNew(3, &(dims[0]), numpy.NPY_UBYTE) + self.bmp_array = numpy.PyArray_SimpleNew(3, dims, numpy.NPY_UBYTE) data = self.bmp_array.data bs = img.tobytes() @@ -2672,7 +2672,7 @@ cdef int bisect_left(PiecewiseLinearColorFunction self, CGFloat t): hi = self.num_stops lo = 0 while lo < hi: - mid = (lo + hi)/2 + mid = (lo + hi) // 2 stop = self.stops[mid] if t < stop: hi = mid @@ -2680,7 +2680,7 @@ cdef int bisect_left(PiecewiseLinearColorFunction self, CGFloat t): lo = mid + 1 return lo -cdef void piecewise_callback(void* obj, CGFloat* t, CGFloat* out): +cdef void piecewise_callback(void* obj, CGFloat* t, CGFloat* out) noexcept: cdef int i cdef CGFloat eps cdef PiecewiseLinearColorFunction self diff --git a/pyproject.toml b/pyproject.toml index 6f13c370a..099dd0828 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["cython<3", "oldest-supported-numpy", "setuptools", "swig", "wheel"] +requires = ["cython", "numpy>2", "setuptools", "swig", "wheel"] build-backend = "setuptools.build_meta" [tool.cibuildwheel] diff --git a/setup.py b/setup.py index 440a7ffac..b823707d7 100644 --- a/setup.py +++ b/setup.py @@ -320,11 +320,6 @@ def macos_extensions(): 'kiva.quartz.ABCGI', sources=[ 'kiva/quartz/ABCGI.pyx', - 'kiva/quartz/Python.pxi', - 'kiva/quartz/numpy.pxi', - 'kiva/quartz/CoreFoundation.pxi', - 'kiva/quartz/CoreGraphics.pxi', - 'kiva/quartz/CoreText.pxi', ], extra_link_args=extra_link_args, include_dirs=[numpy.get_include()], @@ -333,9 +328,6 @@ def macos_extensions(): 'kiva.quartz.CTFont', sources=[ 'kiva/quartz/CTFont.pyx', - 'kiva/quartz/CoreFoundation.pxi', - 'kiva/quartz/CoreGraphics.pxi', - 'kiva/quartz/CoreText.pxi', ], extra_link_args=extra_link_args, ),