From 249dc27019f4992553225ecb6bf4bf634b4ea361 Mon Sep 17 00:00:00 2001 From: Orion Poplawski Date: Sun, 16 Jul 2023 19:52:50 -0600 Subject: [PATCH] Initial Fedora package --- .gitignore | 1 + imagecodecs_distributor_setup.py | 27 +++++ python-imagecodecs.spec | 173 +++++++++++++++++++++++++++++++ sources | 1 + 4 files changed, 202 insertions(+) create mode 100644 .gitignore create mode 100644 imagecodecs_distributor_setup.py create mode 100644 python-imagecodecs.spec create mode 100644 sources diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c397312 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/imagecodecs-2022.9.26.tar.gz diff --git a/imagecodecs_distributor_setup.py b/imagecodecs_distributor_setup.py new file mode 100644 index 0000000..a4ef910 --- /dev/null +++ b/imagecodecs_distributor_setup.py @@ -0,0 +1,27 @@ +def customize_build(EXTENSIONS, OPTIONS): + """Customize build for Fedora""" + + del EXTENSIONS['apng'] # apng patch not commonly available + del EXTENSIONS['bitshuffle'] # Uses 3rdparty source + del EXTENSIONS['brunsli'] # not available on Fedora + del EXTENSIONS['jetraw'] # commercial + del EXTENSIONS['jpeg12'] # jpeg12 requires custom build + del EXTENSIONS['jpegls'] # Fedora's charls is too old at the moment + del EXTENSIONS['jpegxl'] # requires static linking? + del EXTENSIONS['ljpeg'] # Uses 3rdparty source + del EXTENSIONS['lz4f'] # requires static linking + del EXTENSIONS['lzf'] # Uses 3rdparty source + del EXTENSIONS['mozjpeg'] # Win32 only + del EXTENSIONS['pglz'] # Uses 3rdparty source + del EXTENSIONS['qoi'] # Uses 3rdparty source + del EXTENSIONS['rgbe'] # Uses 3rdparty source + del EXTENSIONS['spng'] # Uses 3rdparty source + EXTENSIONS['jpeg2k']['include_dirs'].extend( + ( + '/usr/include/openjpeg-2.4', + '/usr/include/openjpeg-2.5', + ) + ) + del EXTENSIONS['jpeg2k'] # Uses 3rdparty source to use private function - https://github.com/cgohlke/imagecodecs/issues/77 + EXTENSIONS['jpegxr']['include_dirs'].append('/usr/include/jxrlib') + EXTENSIONS['zopfli']['include_dirs'].append('/usr/include/zopfli') diff --git a/python-imagecodecs.spec b/python-imagecodecs.spec new file mode 100644 index 0000000..83326b5 --- /dev/null +++ b/python-imagecodecs.spec @@ -0,0 +1,173 @@ +%global srcname imagecodecs + +Name: python-imagecodecs +# Imagecodecs 2023.3.16 requires libjpeg-turbo 3, which is currently in beta: +# Imagecodecs 2023.1.23-2022.12.22 requires libtiff 4.5.0 +Version: 2022.9.26 +Release: 1%{?dist} +Summary: Image transformation, compression, and decompression codecs + +License: BSD-3-Clause +URL: https://pypi.org/project/imagecodecs/ +Source: %{pypi_source} +# Build configuration +Source1: imagecodecs_distributor_setup.py + +BuildRequires: python3-devel +BuildRequires: python3-Cython +BuildRequires: gcc-c++ +BuildRequires: blosc-devel +BuildRequires: blosc2-devel +BuildRequires: bzip2-devel +BuildRequires: cfitsio-devel +BuildRequires: CharLS-devel +BuildRequires: giflib-devel +BuildRequires: jxrlib-devel +BuildRequires: lcms2-devel +BuildRequires: libaec-devel +BuildRequires: libavif-devel +BuildRequires: libdeflate-devel +BuildRequires: libheif-devel +BuildRequires: libjpeg-turbo-devel +BuildRequires: liblerc-devel +BuildRequires: libpng-devel +BuildRequires: libtiff-devel +BuildRequires: libzstd-devel +BuildRequires: lz4-devel +# Uses 3rdparty source to use private function - https://github.com/cgohlke/imagecodecs/issues/77 +#BuildRequires: openjpeg2-devel +BuildRequires: snappy-devel +BuildRequires: xz-devel +BuildRequires: zfp-devel +BuildRequires: zlib-ng-devel +BuildRequires: zopfli-devel +# Tests +BuildRequires: pytest + +%global _description %{expand: +Imagecodecs is a Python library that provides block-oriented, in-memory +buffer transformation, compression, and decompression functions for use in +Tifffile, Czifile, Zarr, kerchunk, and other scientific image input/output +packages. + +Decode and/or encode functions are implemented for Zlib (DEFLATE), GZIP, +ZStandard (ZSTD), Blosc, Brotli, Snappy, LZMA, BZ2, LZ4, LZ4F, LZ4HC, LZW, +LZF, LZFSE, LZHAM, PGLZ (PostgreSQL LZ), RCOMP (Rice), ZFP, AEC, SZIP, LERC, +NPY, PNG, APNG, GIF, TIFF, WebP, QOI, JPEG 8-bit, JPEG 12-bit, Lossless JPEG +(LJPEG, LJ92, JPEGLL), JPEG 2000 (JP2, J2K), JPEG LS, JPEG XL, JPEG XR (WDP, +HD Photo), MOZJPEG, AVIF, HEIF, RGBE (HDR), Jetraw, PackBits, Packed Integers, +Delta, XOR Delta, Floating Point Predictor, Bitorder reversal, Byteshuffle, +Bitshuffle, CMS (color space transformations), and Float24 (24-bit floating +point).} + +%description %_description + +%package -n python3-imagecodecs +Summary: %{summary} + +%description -n python3-imagecodecs %_description + + +%prep +%autosetup -p1 -n imagecodecs-%{version} +# Copy in configuration +cp -a %SOURCE1 . +# Force regeneration of cython source +rm -f $(grep -rl '/\* Generated by Cython') +# I don't want to deal with 3rdparty sources +rm -r 3rdparty + +%generate_buildrequires +%pyproject_buildrequires + + +%build +export CPPFLAGS=-I%{_includedir}/cfitsio +%pyproject_wheel + + +%install +%pyproject_install +%pyproject_save_files imagecodecs + + +%check +# tifffile is too old at this point to run the tifffile tests +# spng_encode appears to not be available with openjpeg2 disabled, but the test still tries to run +# Other deselected tests seem to be related to unsupported compression types +# A number of tests fail on s390x, ignore that for now +%pytest -v --deselect tests/test_imagecodecs.py::test_tifffile \ + --deselect tests/test_imagecodecs.py::test_spng_encode \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgb-new-new-None]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgb-new-new-5]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgb-new-new--1]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgb-new-out-None]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgb-new-out-5]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgb-new-out--1]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgb-new-bytearray-None]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgb-new-bytearray-5]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgb-new-bytearray--1]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgb-out-new-None]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgb-out-new-5]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgb-out-new--1]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgb-out-out-None]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgb-out-out-5]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgb-out-out--1]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgb-out-bytearray-None]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgb-out-bytearray-5]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgb-out-bytearray--1]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgb-bytearray-new-None]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgb-bytearray-new-5]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgb-bytearray-new--1]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgb-bytearray-out-None]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgb-bytearray-out-5]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgb-bytearray-out--1]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgb-bytearray-bytearray-None]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgb-bytearray-bytearray-5]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgb-bytearray-bytearray--1]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgba-new-new-None]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgba-new-new-5]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgba-new-new--1]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgba-new-out-None]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgba-new-out-5]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgba-new-out--1]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgba-new-bytearray-None]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgba-new-bytearray-5]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgba-new-bytearray--1]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgba-out-new-None]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgba-out-new-5]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgba-out-new--1]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgba-out-out-None]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgba-out-out-5]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgba-out-out--1]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgba-out-bytearray-None]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgba-out-bytearray-5]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgba-out-bytearray--1]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgba-bytearray-new-None]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgba-bytearray-new-5]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgba-bytearray-new--1]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgba-bytearray-out-None]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgba-bytearray-out-5]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgba-bytearray-out--1]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgba-bytearray-bytearray-None]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgba-bytearray-bytearray-5]" \ + --deselect "tests/test_imagecodecs.py::test_image_roundtrips[heif-uint8-rgba-bytearray-bytearray--1]" \ + --deselect "tests/test_imagecodecs.py::test_tiff_files[gray.lerc.u1-False]" \ + --deselect "tests/test_imagecodecs.py::test_tiff_files[gray.lerc.u1-True]" \ + --deselect "tests/test_imagecodecs.py::test_tiff_files[rgb.tiled.lerc.u1-False]" \ + --deselect "tests/test_imagecodecs.py::test_tiff_files[rgb.tiled.lerc.u1-True]" \ + --deselect "tests/test_imagecodecs.py::test_numcodecs[heif-gray]" \ + --deselect "tests/test_imagecodecs.py::test_numcodecs[heif-rgb]" \ +%ifarch s390x + || exit 0 +%endif + +%files -n python3-imagecodecs -f %{pyproject_files} +%license LICENSE +%doc README.* +%{_bindir}/imagecodecs + + +%changelog +* Fri Jun 02 2023 Orion Poplawski - 2022.9.26-1 +- Initial Fedora package diff --git a/sources b/sources new file mode 100644 index 0000000..6b3cc8e --- /dev/null +++ b/sources @@ -0,0 +1 @@ +SHA512 (imagecodecs-2022.9.26.tar.gz) = 3f1fd8f475e19ec12b52797c58afd49581be495acd59380cd145ed3d60719b55f4cfffaf0a5564595de058b9a3cfb4ff2ec43ed507d0a1cb6c90d7eb7cc9ea48