1
0

Accepting request 1110636 from home:mcalabkova:branches:devel:languages:python

- Add patch cython3.patch to fix build

OBS-URL: https://build.opensuse.org/request/show/1110636
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-imagecodecs?expand=0&rev=23
This commit is contained in:
Dirk Mueller 2023-09-13 07:39:12 +00:00 committed by Git OBS Bridge
parent 9b87025fae
commit 502793a086
3 changed files with 124 additions and 0 deletions

117
cython3.patch Normal file
View File

@ -0,0 +1,117 @@
From 14bb6012a8c9f48df264ea996f3376e57166201a Mon Sep 17 00:00:00 2001
From: Christoph Gohlke <cgohlke@cgohlke.com>
Date: Mon, 3 Jul 2023 09:41:26 -0700
Subject: [PATCH] Update imagecodecs/_heif.pyx
---
imagecodecs/_heif.pyx | 41 ++++++++++++++++++++++-------------------
1 file changed, 22 insertions(+), 19 deletions(-)
Index: imagecodecs-2023.3.16/imagecodecs/_heif.pyx
===================================================================
--- imagecodecs-2023.3.16.orig/imagecodecs/_heif.pyx
+++ imagecodecs-2023.3.16/imagecodecs/_heif.pyx
@@ -61,9 +61,9 @@ class HEIF:
AVC = heif_compression_AVC
JPEG = heif_compression_JPEG
AV1 = heif_compression_AV1
- # VVC = heif_compression_VVC
- # EVC = heif_compression_EVC
- # JPEG2000 = heif_compression_JPEG2000
+ VVC = heif_compression_VVC
+ EVC = heif_compression_EVC
+ JPEG2000 = heif_compression_JPEG2000
class COLORSPACE(enum.IntEnum):
"""HEIF codec color spaces."""
@@ -145,13 +145,13 @@ def heif_encode(
uint16_t* a2ptr = NULL
if not (
- src.dtype in (numpy.uint8, numpy.uint16)
+ src.dtype in {numpy.uint8, numpy.uint16}
# and numpy.PyArray_ISCONTIGUOUS(src)
- and src.ndim in (2, 3, 4)
- and src.shape[0] < 2 ** 32
- and src.shape[1] < 2 ** 32
- and src.shape[src.ndim - 1] < 2 ** 32
- and src.shape[src.ndim - 2] < 2 ** 32
+ and src.ndim in {2, 3, 4}
+ and src.shape[0] < 4294967296
+ and src.shape[1] < 4294967296
+ and src.shape[src.ndim - 1] < 4294967296
+ and src.shape[src.ndim - 2] < 4294967296
):
raise ValueError('invalid data shape, strides, or dtype')
@@ -184,14 +184,14 @@ def heif_encode(
raise ValueError(f'{src.ndim} dimensions not supported')
monochrome = samples < 3
- hasalpha = samples in (2, 4)
+ hasalpha = samples in {2, 4}
if bitspersample is None:
depth = 8 if itemsize == 1 else 10
else:
depth = bitspersample
if (
- depth not in (8, 10, 12)
+ depth not in {8, 10, 12}
or (depth == 8 and itemsize == 2)
or (depth > 8 and itemsize == 1)
):
@@ -721,12 +721,12 @@ cdef _heif_photometric(photometric):
"""Return heif_colorspace value from photometric argument."""
if photometric is None:
return heif_colorspace_undefined
- if photometric in (
+ if photometric in {
heif_colorspace_undefined,
heif_colorspace_YCbCr,
heif_colorspace_RGB,
heif_colorspace_monochrome,
- ):
+ }:
return photometric
if isinstance(photometric, str):
photometric = photometric.upper()
@@ -734,9 +734,9 @@ cdef _heif_photometric(photometric):
return heif_colorspace_RGB
if photometric[:3] == 'YCBCR':
return heif_colorspace_YCbCr
- if photometric in (
+ if photometric in {
'GRAY', 'BLACKISZERO', 'MINISBLACK', 'WHITEISZERO', 'MINISWHITE'
- ):
+ }:
return heif_colorspace_monochrome
raise ValueError(f'photometric {photometric!r} not supported')
@@ -745,7 +745,7 @@ cdef _heif_compression(compression):
"""Return heif_compression_format value from compression argument."""
if compression is None:
return heif_compression_HEVC
- if compression in (
+ if compression in {
heif_compression_undefined,
heif_compression_HEVC,
heif_compression_AVC,
@@ -754,7 +754,7 @@ cdef _heif_compression(compression):
# heif_compression_VVC,
# heif_compression_EVC,
# heif_compression_JPEG2000,
- ):
+ }:
return compression
if isinstance(compression, str):
compression = compression.upper()
@@ -782,7 +782,7 @@ cdef heif_error heif_write_callback(
const void* data,
size_t size,
void* userdata
-) nogil:
+) noexcept nogil:
"""heif_writer callback function."""
cdef:
output_t* output = <output_t*> userdata

View File

@ -1,3 +1,8 @@
-------------------------------------------------------------------
Tue Sep 12 14:21:29 UTC 2023 - Markéta Machová <mmachova@suse.com>
- Add patch cython3.patch to fix build
-------------------------------------------------------------------
Fri Mar 24 14:31:16 UTC 2023 - Ben Greiner <code@bnavigator.de>

View File

@ -34,6 +34,8 @@ URL: https://github.com/cgohlke/imagecodecs/
Source: https://files.pythonhosted.org/packages/source/i/imagecodecs/imagecodecs-%{version}.tar.gz
Source1: imagecodecs_distributor_setup.py
Patch0: always-cythonize.patch
# PATCH-FIX-UPSTREAM https://github.com/cgohlke/imagecodecs/commit/14bb6012a8c9f48df264ea996f3376e57166201a Update imagecodecs/_heif.pyx
Patch1: cython3.patch
BuildRequires: %{python_module Cython >= 0.29.19}
BuildRequires: %{python_module base >= 3.8}
BuildRequires: %{python_module numpy-devel}