cgohlke / imagecodecs

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

Cannot disable bcn #97

Closed opoplawski closed 9 months ago

opoplawski commented 9 months ago

I'm trying to update the Fedora imagecodecs package to 2024.1.1. We don't want to build with 3rd party sources, so we disable a bunch of codecs. I'm currently hitting:

  Compiling imagecodecs/_bcn.pyx because it changed.
  [1/1] Cythonizing imagecodecs/_bcn.pyx
  building 'imagecodecs._bcn' extension
  gcc -fno-strict-overflow -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -fcf-protection -fexceptions -fcf-protection -fexceptions -fcf-protection -fexceptions -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 -march=x86-64 -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.12 -I/usr/lib64/python3.12/site-packages/numpy/core/include -c imagecodecs/_bcn.c -o build/temp.linux-x86_64-cpython-312/imagecodecs/_bcn.o
  In file included from /usr/lib64/python3.12/site-packages/numpy/core/include/numpy/ndarraytypes.h:1929,
                   from /usr/lib64/python3.12/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,
                   from /usr/lib64/python3.12/site-packages/numpy/core/include/numpy/arrayobject.h:5,
                   from imagecodecs/_bcn.c:1225:
  /usr/lib64/python3.12/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
     17 | #warning "Using deprecated NumPy API, disable it with " \
        |  ^~~~~~~
  imagecodecs/_bcn.c:1232:10: fatal error: bcdec.h: No such file or directory
   1232 | #include "bcdec.h"
        |          ^~~~~~~~~

Even though I am disabling it in 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
....

More background - we delete the cython generated files so that they get regenerated. But I would have hoped that _bcn would have been skipped because it was disabled.

opoplawski commented 9 months ago

Hmm, it seems like all of my attempts at disabling extensions are failing now. Has something changed with how we are supposed to disable them?

opoplawski commented 9 months ago

So it looks like things have changed on the Fedora end in that '.' is not longer in the default path. Perhaps the import in setup.py can be made more explicit? Or is it meant to be able to be imported from anywhere?

cgohlke commented 9 months ago

'.' is not longer in the default path

That would have been my first guess too. The directory where imagecodecs_distributor_setup.py is stored needs to be in Python's sys.path. Try setting the PYTHONPATH environment variable before building.