cgohlke / imagecodecs

Image transformation, compression, and decompression codecs
https://pypi.org/project/imagecodecs
BSD 3-Clause "New" or "Revised" License
121 stars 24 forks source link

Cannot disable bcn extension #80

Closed opoplawski closed 1 year ago

opoplawski commented 1 year ago

I'm trying to disable the bcn extension. I have the following for imagecodecs_distributor_setup.py:

def customize_build(EXTENSIONS, OPTIONS):
    """Customize build for Fedora"""

    del EXTENSIONS['apng']  # apng patch not commonly available
    del EXTENSIONS['bcn']  # Uses 3rdparty source
    del EXTENSIONS['bitshuffle']  # Uses 3rdparty source
    del EXTENSIONS['brunsli']  # not available on Fedora
    del EXTENSIONS['jetraw']  # commercial
    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')

but it still tries to compile imagecodecs/_bcn.c. How can I prevent that? Thanks.

cgohlke commented 1 year ago

I cannot reproduce the issue. Works as expected here.

opoplawski commented 1 year ago

So, I'm deleting the 3rdparty directory t o ensure that I'm not using in there. Then we build:

+ /usr/bin/python3 -Bs /usr/lib/rpm/redhat/pyproject_wheel.py /home/orion/python-imagecodecs/imagecodecs-2023.7.10/pyproject-wheeldir
Processing /home/orion/python-imagecodecs/imagecodecs-2023.7.10
  Preparing metadata (pyproject.toml): started
  Running command Preparing metadata (pyproject.toml)
  running dist_info
  creating /home/orion/python-imagecodecs/imagecodecs-2023.7.10/.pyproject-builddir/pip-modern-metadata-1_xoeowj/imagecodecs.egg-info
  writing /home/orion/python-imagecodecs/imagecodecs-2023.7.10/.pyproject-builddir/pip-modern-metadata-1_xoeowj/imagecodecs.egg-info/PKG-INFO
  writing dependency_links to /home/orion/python-imagecodecs/imagecodecs-2023.7.10/.pyproject-builddir/pip-modern-metadata-1_xoeowj/imagecodecs.egg-info/dependency_links.txt
  writing entry points to /home/orion/python-imagecodecs/imagecodecs-2023.7.10/.pyproject-builddir/pip-modern-metadata-1_xoeowj/imagecodecs.egg-info/entry_points.txt
  writing requirements to /home/orion/python-imagecodecs/imagecodecs-2023.7.10/.pyproject-builddir/pip-modern-metadata-1_xoeowj/imagecodecs.egg-info/requires.txt
  writing top-level names to /home/orion/python-imagecodecs/imagecodecs-2023.7.10/.pyproject-builddir/pip-modern-metadata-1_xoeowj/imagecodecs.egg-info/top_level.txt
  writing manifest file '/home/orion/python-imagecodecs/imagecodecs-2023.7.10/.pyproject-builddir/pip-modern-metadata-1_xoeowj/imagecodecs.egg-info/SOURCES.txt'
  reading manifest file '/home/orion/python-imagecodecs/imagecodecs-2023.7.10/.pyproject-builddir/pip-modern-metadata-1_xoeowj/imagecodecs.egg-info/SOURCES.txt'
  reading manifest template 'MANIFEST.in'
  warning: no previously-included files found matching 'imagecodecs/_*.c'
  warning: no files found matching 'imagecodecs/*.cpp'
  warning: no files found matching 'imagecodecs/patches/*'
  warning: no files found matching '3rdparty/*'
  warning: no files found matching '3rdparty/*/*'
  warning: no files found matching 'tests/*.zfp'
  warning: no files found matching 'tests/*.icc'
  warning: no files found matching 'tests/*.jxl'
  warning: no files found matching 'tests/*.tif'
  warning: no files found matching 'tests/*.apng'
  warning: no previously-included files found matching 'tests/libaec/121B2TestData/ExtendedParameters/*.*'
  warning: no previously-included files found matching 'tests/tiff/gray.movie.*.tif'
  warning: no previously-included files found matching 'tests/ljpeg/dcm*.ljp'
  warning: no previously-included files found matching 'tests/ljpeg/2ch.ljp'
  warning: no previously-included files found matching 'tests/ljpeg/pvrg.ljp'
  warning: no previously-included files found matching 'tests/bcn/*.dds'
  warning: no previously-included files found matching 'tests/33792x79872.jpg'
  warning: no previously-included files found matching 'tests/jpegxr.czi'
  warning: no previously-included files found matching 'tests/jetraw.bin'
  warning: no previously-included files found matching '*.cmd'
  warning: no previously-included files found matching 'build_utils/*'
  warning: no previously-included files matching '*' found under directory 'doc'
  warning: no previously-included files matching '*' found under directory 'docs'
  warning: no previously-included files matching '__pycache__' found under directory '*'
  warning: no previously-included files matching '*.py[co]' found under directory '*'
  warning: no previously-included files matching '*-' found under directory '*'
  warning: no previously-included files matching '*.html' found under directory '*'
  warning: no previously-included files matching '*Copy*.*' found under directory '*'
  adding license file 'LICENSE'
  writing manifest file '/home/orion/python-imagecodecs/imagecodecs-2023.7.10/.pyproject-builddir/pip-modern-metadata-1_xoeowj/imagecodecs.egg-info/SOURCES.txt'
  creating '/home/orion/python-imagecodecs/imagecodecs-2023.7.10/.pyproject-builddir/pip-modern-metadata-1_xoeowj/imagecodecs-2023.7.10.dist-info'
  Preparing metadata (pyproject.toml): finished with status 'done'
Building wheels for collected packages: imagecodecs
  Building wheel for imagecodecs (pyproject.toml): started
  Running command Building wheel for imagecodecs (pyproject.toml)
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-cpython-311
  creating build/lib.linux-x86_64-cpython-311/imagecodecs
  copying imagecodecs/__main__.py -> build/lib.linux-x86_64-cpython-311/imagecodecs
  copying imagecodecs/__init__.py -> build/lib.linux-x86_64-cpython-311/imagecodecs
  copying imagecodecs/numcodecs.py -> build/lib.linux-x86_64-cpython-311/imagecodecs
  copying imagecodecs/imagecodecs.py -> build/lib.linux-x86_64-cpython-311/imagecodecs
  copying imagecodecs/_imagecodecs.py -> build/lib.linux-x86_64-cpython-311/imagecodecs
  copying imagecodecs/__init__.pyi -> build/lib.linux-x86_64-cpython-311/imagecodecs
  creating build/lib.linux-x86_64-cpython-311/imagecodecs/licenses
  copying imagecodecs/licenses/LICENSE-libjpeg-turbo -> build/lib.linux-x86_64-cpython-311/imagecodecs/licenses
  copying imagecodecs/licenses/LICENSE-zopfli -> build/lib.linux-x86_64-cpython-311/imagecodecs/licenses
  copying imagecodecs/licenses/LICENSE-blosc -> build/lib.linux-x86_64-cpython-311/imagecodecs/licenses
  copying imagecodecs/licenses/LICENSE-jetraw -> build/lib.linux-x86_64-cpython-311/imagecodecs/licenses
  copying imagecodecs/licenses/LICENSE-aom -> build/lib.linux-x86_64-cpython-311/imagecodecs/licenses
  copying imagecodecs/licenses/LICENSE-libjpeg -> build/lib.linux-x86_64-cpython-311/imagecodecs/licenses
  copying imagecodecs/licenses/LICENSE-fastlz -> build/lib.linux-x86_64-cpython-311/imagecodecs/licenses
  copying imagecodecs/licenses/LICENSE-brunsli -> build/lib.linux-x86_64-cpython-311/imagecodecs/licenses
  copying imagecodecs/licenses/LICENSE-brotli -> build/lib.linux-x86_64-cpython-311/imagecodecs/licenses
  copying imagecodecs/licenses/LICENSE-bitshuffle -> build/lib.linux-x86_64-cpython-311/imagecodecs/licenses
  copying imagecodecs/licenses/LICENSE-lcms2 -> build/lib.linux-x86_64-cpython-311/imagecodecs/licenses
  copying imagecodecs/licenses/LICENSE-libspng -> build/lib.linux-x86_64-cpython-311/imagecodecs/licenses
  copying imagecodecs/licenses/LICENSE-libpng -> build/lib.linux-x86_64-cpython-311/imagecodecs/licenses
  copying imagecodecs/licenses/LICENSE-zstd -> build/lib.linux-x86_64-cpython-311/imagecodecs/licenses
  copying imagecodecs/licenses/LICENSE-mozjpeg -> build/lib.linux-x86_64-cpython-311/imagecodecs/licenses
  copying imagecodecs/licenses/LICENSE-bzip2 -> build/lib.linux-x86_64-cpython-311/imagecodecs/licenses
  copying imagecodecs/licenses/LICENSE-jpg_0xc3 -> build/lib.linux-x86_64-cpython-311/imagecodecs/licenses
  copying imagecodecs/licenses/LICENSE-dav1d -> build/lib.linux-x86_64-cpython-311/imagecodecs/licenses
  copying imagecodecs/licenses/LICENSE-lz4 -> build/lib.linux-x86_64-cpython-311/imagecodecs/licenses
  copying imagecodecs/licenses/LICENSE-lzham -> build/lib.linux-x86_64-cpython-311/imagecodecs/licenses
  copying imagecodecs/licenses/LICENSE-libtiff -> build/lib.linux-x86_64-cpython-311/imagecodecs/licenses
  copying imagecodecs/licenses/LICENSE-libjxl -> build/lib.linux-x86_64-cpython-311/imagecodecs/licenses
  copying imagecodecs/licenses/LICENSE-liblzma -> build/lib.linux-x86_64-cpython-311/imagecodecs/licenses
  copying imagecodecs/licenses/LICENSE-openjpeg -> build/lib.linux-x86_64-cpython-311/imagecodecs/licenses
  copying imagecodecs/licenses/LICENSE-rav1e -> build/lib.linux-x86_64-cpython-311/imagecodecs/licenses
  copying imagecodecs/licenses/LICENSE-blosc2 -> build/lib.linux-x86_64-cpython-311/imagecodecs/licenses
  copying imagecodecs/licenses/LICENSE-libaivf -> build/lib.linux-x86_64-cpython-311/imagecodecs/licenses
  copying imagecodecs/licenses/LICENSE-postgresql -> build/lib.linux-x86_64-cpython-311/imagecodecs/licenses
  copying imagecodecs/licenses/LICENSE-svt-av1 -> build/lib.linux-x86_64-cpython-311/imagecodecs/licenses
  copying imagecodecs/licenses/LICENSE-libaec -> build/lib.linux-x86_64-cpython-311/imagecodecs/licenses
  copying imagecodecs/licenses/LICENSE-zfp -> build/lib.linux-x86_64-cpython-311/imagecodecs/licenses
  copying imagecodecs/licenses/LICENSE-liblj92 -> build/lib.linux-x86_64-cpython-311/imagecodecs/licenses
  copying imagecodecs/licenses/LICENSE-libwebp -> build/lib.linux-x86_64-cpython-311/imagecodecs/licenses
  copying imagecodecs/licenses/PATENTS-rav1e -> build/lib.linux-x86_64-cpython-311/imagecodecs/licenses
  copying imagecodecs/licenses/LICENSE-snappy -> build/lib.linux-x86_64-cpython-311/imagecodecs/licenses
  copying imagecodecs/licenses/LICENSE-lzfse -> build/lib.linux-x86_64-cpython-311/imagecodecs/licenses
  copying imagecodecs/licenses/LICENSE-lerc -> build/lib.linux-x86_64-cpython-311/imagecodecs/licenses
  copying imagecodecs/licenses/LICENSE-libdeflate -> build/lib.linux-x86_64-cpython-311/imagecodecs/licenses
  copying imagecodecs/licenses/LICENSE-jxrlib -> build/lib.linux-x86_64-cpython-311/imagecodecs/licenses
  copying imagecodecs/licenses/LICENSE-zlib -> build/lib.linux-x86_64-cpython-311/imagecodecs/licenses
  copying imagecodecs/licenses/LICENSE-libmng -> build/lib.linux-x86_64-cpython-311/imagecodecs/licenses
  copying imagecodecs/licenses/LICENSE-charls -> build/lib.linux-x86_64-cpython-311/imagecodecs/licenses
  copying imagecodecs/licenses/LICENSE-jpeg -> build/lib.linux-x86_64-cpython-311/imagecodecs/licenses
  copying imagecodecs/licenses/LICENSE-zlib-ng -> build/lib.linux-x86_64-cpython-311/imagecodecs/licenses
  copying imagecodecs/licenses/LICENSE-cfitsio -> build/lib.linux-x86_64-cpython-311/imagecodecs/licenses
  copying imagecodecs/licenses/LICENSE-giflib -> build/lib.linux-x86_64-cpython-311/imagecodecs/licenses
  copying imagecodecs/licenses/LICENSE-bcdec -> build/lib.linux-x86_64-cpython-311/imagecodecs/licenses
  copying imagecodecs/licenses/LICENSE-qoi -> build/lib.linux-x86_64-cpython-311/imagecodecs/licenses
  copying imagecodecs/licenses/LICENSE-lzf -> build/lib.linux-x86_64-cpython-311/imagecodecs/licenses
  copying imagecodecs/licenses/LICENSE-highway -> build/lib.linux-x86_64-cpython-311/imagecodecs/licenses
  running build_ext
  cythoning imagecodecs/_aec.pyx to imagecodecs/_aec.c
  INFO: Disabling color, you really want to install colorlog.
  Disabling color, you really want to install colorlog.
  error: Command "gcc -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -I/usr/include/cfitsio -fPIC -DBCDEC_STATIC=1 -DBCDEC_IMPLEMENTATION=1 -Iimagecodecs -I3rdparty/bcdec -I/usr/include/python3.11 -I/usr/lib64/python3.11/site-packages/numpy/core/include -c imagecodecs/_bcn.c -o build/temp.linux-x86_64-cpython-311/imagecodecs/_bcn.o" failed with exit status 1
  error: subprocess-exited-with-error

But why is it trying to build _bcn.o?

opoplawski commented 1 year ago

I think I've finally sorted it out - the build no longer includes . in PYTHONPATH so it wasn't importing imagecodecs_distributor_setup. Setting PYTHONPATH=. resolved it.

opoplawski commented 1 year ago

Should setup.py explicitly do from .imagecodecs_distributor_setup... ?