cgohlke / imagecodecs

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

error: use of undeclared identifier 'JPEG_LIB_VERSION_MAJOR' #22

Closed Schamschula closed 3 years ago

Schamschula commented 3 years ago

While building py39-imagecodecs 2021.8.26 under MacPorts I get the following error:

:info:build In file included from imagecodecs/_jpegsof3.c:620:
:info:build In file included from /opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/numpy/core/include/numpy/arrayobject.h:4:
:info:build In file included from /opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/numpy/core/include/numpy/ndarrayobject.h:12:
:info:build In file included from /opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/numpy/core/include/numpy/ndarraytypes.h:1969:
:info:build /opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: "Using deprecated NumPy API, disable it with "          "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-W#warnings]
:info:build #warning "Using deprecated NumPy API, disable it with " \
:info:build  ^
:info:build building 'imagecodecs._ljpeg' extension
:info:build creating build/temp.macosx-10.14-x86_64-3.9/3rdparty/liblj92
:info:build imagecodecs/_jpeg8.c:2928:40: error: use of undeclared identifier 'JPEG_LIB_VERSION_MAJOR'
:info:build   __pyx_t_4 = __Pyx_PyUnicode_From_int(JPEG_LIB_VERSION_MAJOR, 0, ' ', 'd'); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 91, __pyx_L1_error)
:info:build                                        ^
:info:build /opt/local/var/macports/build/_Users_marius_Development_MacPorts_ports_python_py-imagecodecs/py39-imagecodecs/work/compwrap/cc/usr/bin/clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -pipe -Os -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk -arch x86_64 -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk -Iimagecodecs -I3rdparty/liblj92 -I/opt/local/Library/Frameworks/Python.framework/Versions/3.9/include/python3.9 -I/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/numpy/core/include -c 3rdparty/liblj92/lj92.c -o build/temp.macosx-10.14-x86_64-3.9/3rdparty/liblj92/lj92.o
:info:build imagecodecs/_jpeg8.c:2938:40: error: use of undeclared identifier 'JPEG_LIB_VERSION_MINOR'
:info:build   __pyx_t_4 = __Pyx_PyUnicode_From_int(JPEG_LIB_VERSION_MINOR, 0, ' ', 'd'); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 91, __pyx_L1_error)
:info:build                                        ^
:info:build 1 warning and 2 errors generated.
cgohlke commented 3 years ago

What's the Cython version?

Schamschula commented 3 years ago

The following ports are currently installed: py39-cython @0.29.24_0 (active)

cgohlke commented 3 years ago

Bummer. Looks like cython_compile_time_env and/or force cythonize are not working as on my system. Can you try to delete the Cython generated files (_*.c) and build again?

Schamschula commented 3 years ago

I tried building several times, each time starting with a clean directory tree. I got the same error each time.

cgohlke commented 3 years ago

I see. It looks like MacPorts switched from libjpeg to libjpeg-turbo some months ago and you are the first to notice/report. In that case these lines should be removed: https://github.com/cgohlke/imagecodecs/blob/8eec683f117b44c178785f542831f530511608ff/setup.py#L473-L476

Schamschula commented 3 years ago

I previously made some changes (a patchfile) to account for that. However, my previous patch needed to be modified for today's version. I already have tried a commenting out lines 474-476, but had left 473 in place. I'll try commenting out that line as well.

Schamschula commented 3 years ago

Indeed. That fixes it! I've updated the patch. Go ahead and remove those lines in the next update. https://github.com/macports/macports-ports/commit/26d1489eafc39b980a891674875784101e837d03

cgohlke commented 3 years ago

Thank you for reporting the issue.