Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not build on ARM CPU #25

Closed
rphlo opened this issue May 3, 2024 · 8 comments
Closed

Does not build on ARM CPU #25

rphlo opened this issue May 3, 2024 · 8 comments

Comments

@rphlo
Copy link
Contributor

rphlo commented May 3, 2024

Trying to install it on ARM CPU (M1 Mac mini)
Fails both inside docker build (python-slim image) or on MacOS

error: subprocess-exited-with-error

  × Building wheel for jxlpy (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [26 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.macosx-12.6-arm64-cpython-311
      creating build/lib.macosx-12.6-arm64-cpython-311/jxlpy
      copying jxlpy/JXLImagePlugin.py -> build/lib.macosx-12.6-arm64-cpython-311/jxlpy
      copying jxlpy/__init__.py -> build/lib.macosx-12.6-arm64-cpython-311/jxlpy
      running egg_info
      writing jxlpy.egg-info/PKG-INFO
      writing dependency_links to jxlpy.egg-info/dependency_links.txt
      writing requirements to jxlpy.egg-info/requires.txt
      writing top-level names to jxlpy.egg-info/top_level.txt
      reading manifest file 'jxlpy.egg-info/SOURCES.txt'
      adding license file 'LICENSE'
      writing manifest file 'jxlpy.egg-info/SOURCES.txt'
      running build_ext
      building '_jxlpy' extension
      creating build/temp.macosx-12.6-arm64-cpython-311
      creating build/temp.macosx-12.6-arm64-cpython-311/_jxlpy
      clang -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/Users/rphlo/.pyenv/versions/3.11.0/include/python3.11 -c _jxlpy/_jxl.cpp -o build/temp.macosx-12.6-arm64-cpython-311/_jxlpy/_jxl.o -O2
      _jxlpy/_jxl.cpp:1240:10: fatal error: 'jxl/types.h' file not found
      #include "jxl/types.h"
               ^~~~~~~~~~~~~
      1 error generated.
      error: command '/usr/bin/clang' failed with exit code 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for jxlpy
ERROR: Could not build wheels for jxlpy, which is required to install pyproject.toml-based projects
@rphlo rphlo changed the title Doesnt compile install on ARM CPU Does not build on ARM CPU May 3, 2024
@olokelo
Copy link
Owner

olokelo commented May 3, 2024

Looking at error message you got I suspect you might not have libjxl development headers installed on your system. They're needed to build since jxlpy interfaces with libjxl. Could you please try installing libjxl package or alternatively compiling libjxl from source?

@rphlo
Copy link
Contributor Author

rphlo commented May 3, 2024

in docker I have a step installing libjxl-dev

Error message is following:

#20 27.12 error: Failed to download distributions
#20 27.12   Caused by: Failed to fetch wheel: jxlpy==0.9.4
#20 27.12   Caused by: Failed to build: `jxlpy==0.9.4`
#20 27.12   Caused by: Build backend failed to build wheel through `build_wheel()` with exit status: 1
#20 27.12 --- stdout:
#20 27.12 running bdist_wheel
#20 27.12 running build
#20 27.12 running build_py
#20 27.12 creating build
#20 27.12 creating build/lib.linux-aarch64-cpython-312
#20 27.12 creating build/lib.linux-aarch64-cpython-312/jxlpy
#20 27.12 copying jxlpy/__init__.py -> build/lib.linux-aarch64-cpython-312/jxlpy
#20 27.12 copying jxlpy/JXLImagePlugin.py -> build/lib.linux-aarch64-cpython-312/jxlpy
#20 27.12 running egg_info
#20 27.12 writing jxlpy.egg-info/PKG-INFO
#20 27.12 writing dependency_links to jxlpy.egg-info/dependency_links.txt
#20 27.12 writing requirements to jxlpy.egg-info/requires.txt
#20 27.12 writing top-level names to jxlpy.egg-info/top_level.txt
#20 27.12 reading manifest file 'jxlpy.egg-info/SOURCES.txt'
#20 27.12 adding license file 'LICENSE'
#20 27.12 writing manifest file 'jxlpy.egg-info/SOURCES.txt'
#20 27.12 copying jxlpy/__init__.py -> build/lib.linux-aarch64-cpython-312/jxlpy
#20 27.12 copying jxlpy/JXLImagePlugin.py -> build/lib.linux-aarch64-cpython-312/jxlpy
#20 27.12 running build_ext
#20 27.12 building '_jxlpy' extension
#20 27.12 creating build/temp.linux-aarch64-cpython-312
#20 27.12 creating build/temp.linux-aarch64-cpython-312/_jxlpy
#20 27.12 gcc -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O3 -Wall -fPIC -I/root/.cache/uv/.tmpCqIjhO/.venv/include -I/usr/local/include/python3.12 -c _jxlpy/_jxl.cpp -o build/temp.linux-aarch64-cpython-312/_jxlpy/_jxl.o -O2
#20 27.12 --- stderr:
#20 27.12 warning: build_py: byte-compiling is disabled, skipping.
#20 27.12 
#20 27.12 _jxlpy/_jxl.cpp: In function ‘PyObject* __pyx_pf_6_jxlpy_12JXLPyDecoder_10get_info(__pyx_obj_6_jxlpy_JXLPyDecoder*)’:
#20 27.12 _jxlpy/_jxl.cpp:10482:81: error: cannot convert ‘JxlColorProfileTarget’ to ‘const JxlPixelFormat*’
#20 27.12 10482 |       __pyx_v_self->status = JxlDecoderGetICCProfileSize(__pyx_v_self->decoder, JXL_COLOR_PROFILE_TARGET_DATA, (&__pyx_v_icc_profile_size));
#20 27.12       |                                                                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#20 27.12       |                                                                                 |
#20 27.12       |                                                                                 JxlColorProfileTarget
#20 27.12 In file included from _jxlpy/_jxl.cpp:1246:
#20 27.12 /usr/include/jxl/decode.h:794:50: note:   initializing argument 2 of ‘JxlDecoderStatus JxlDecoderGetICCProfileSize(const JxlDecoder*, const JxlPixelFormat*, JxlColorProfileTarget, size_t*)’
#20 27.12   794 |     const JxlDecoder* dec, const JxlPixelFormat* unused_format,
#20 27.12       |                            ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
#20 27.12 _jxlpy/_jxl.cpp:10562:84: error: cannot convert ‘JxlColorProfileTarget’ to ‘const JxlPixelFormat*’
#20 27.12 10562 |       __pyx_v_self->status = JxlDecoderGetColorAsICCProfile(__pyx_v_self->decoder, JXL_COLOR_PROFILE_TARGET_DATA, __pyx_v_self->icc_profile.data(), __pyx_v_self->icc_profile.size());
#20 27.12       |                                                                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#20 27.12       |                                                                                    |
#20 27.12       |                                                                                    JxlColorProfileTarget
#20 27.12 /usr/include/jxl/decode.h:814:50: note:   initializing argument 2 of ‘JxlDecoderStatus JxlDecoderGetColorAsICCProfile(const JxlDecoder*, const JxlPixelFormat*, JxlColorProfileTarget, uint8_t*, size_t)’
#20 27.12   814 |     const JxlDecoder* dec, const JxlPixelFormat* unused_format,
#20 27.12       |                            ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
#20 27.12 error: command '/usr/bin/gcc' failed with exit code 1
#20 27.12 ---

@olokelo
Copy link
Owner

olokelo commented May 4, 2024

What image are you using for your container?

I suspect it's installing an older version of libjxl.
API definitions included in jxlpy are updated for libjxl >=0.9.0. There was an API change in JxlDecoderGetColorAsICCProfile introduced in 0.9.0.
old definition
new one

You may try building libjxl yourself in the container. Also Alpine edge is shipping with libjxl 0.9.1 which would probably work although I can't recommend using it for anything other than testing.

@rphlo
Copy link
Contributor Author

rphlo commented May 4, 2024

docker image is python:3.12 which is based on debian bookworm

@olokelo
Copy link
Owner

olokelo commented May 4, 2024

Debian bookworm ships with libjxl 0.7.0. There're no jxlpy prebuilt wheels for arm architecture yet so that's probably why you need to build it from source.
Could you try building and installing more recent libjxl version in docker container/macos host and then try to install jxlpy?
You can look at official libjxl instructions and also at this repo's workflows.

@yoonthegoon
Copy link

still having this issue on M2 mac.

  • install libjxl with brew install jpeg-xl
  • cjxl --version or djxl --version is djxl v0.10.3 0.10.3 [NEON]
  • types.h in ls /op/homebrew/include/jxl/
  • pip install jxlpy or pip install git+https://github.com/olokelo/jxlpy
Collecting jxlpy
  Using cached jxlpy-0.9.5.tar.gz (107 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting cython (from jxlpy)
  Using cached Cython-3.0.11-py2.py3-none-any.whl.metadata (3.2 kB)
Using cached Cython-3.0.11-py2.py3-none-any.whl (1.2 MB)
Building wheels for collected packages: jxlpy
  Building wheel for jxlpy (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Building wheel for jxlpy (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [26 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.macosx-14.0-arm64-cpython-312
      creating build/lib.macosx-14.0-arm64-cpython-312/jxlpy
      copying jxlpy/JXLImagePlugin.py -> build/lib.macosx-14.0-arm64-cpython-312/jxlpy
      copying jxlpy/__init__.py -> build/lib.macosx-14.0-arm64-cpython-312/jxlpy
      running egg_info
      writing jxlpy.egg-info/PKG-INFO
      writing dependency_links to jxlpy.egg-info/dependency_links.txt
      writing requirements to jxlpy.egg-info/requires.txt
      writing top-level names to jxlpy.egg-info/top_level.txt
      reading manifest file 'jxlpy.egg-info/SOURCES.txt'
      adding license file 'LICENSE'
      writing manifest file 'jxlpy.egg-info/SOURCES.txt'
      running build_ext
      building '_jxlpy' extension
      creating build/temp.macosx-14.0-arm64-cpython-312
      creating build/temp.macosx-14.0-arm64-cpython-312/_jxlpy
      clang++ -fno-strict-overflow -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk -I/Users/yunis/dev/github.com/yoonthegoon/Pillow/.venv/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.12/include/python3.12 -c _jxlpy/_jxl.cpp -o build/temp.macosx-14.0-arm64-cpython-312/_jxlpy/_jxl.o -O2
      _jxlpy/_jxl.cpp:1275:10: fatal error: 'jxl/types.h' file not found
       1275 | #include "jxl/types.h"
            |          ^~~~~~~~~~~~~
      1 error generated.
      error: command '/opt/homebrew/opt/llvm/bin/clang++' failed with exit code 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for jxlpy
Failed to build jxlpy
ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (jxlpy)

@C0rn3j
Copy link

C0rn3j commented Dec 17, 2024

@olokelo please reopen this.

Maybe adding /opt/homebrew/include as an include dir would do the trick?

jxlpy/setup.py

Line 13 in c610bde

include_dirs=[],

EDIT: Kinda, got it compiling:

brew install jpeg-xl
export CXXFLAGS="-I/opt/homebrew/include"
export LDFLAGS="-L/opt/homebrew/lib"
pip install jxlpy

@joneavila
Copy link

@olokelo please reopen this.

Maybe adding /opt/homebrew/include as an include dir would do the trick?

jxlpy/setup.py

Line 13 in c610bde

include_dirs=[],
EDIT: Kinda, got it compiling:

brew install jpeg-xl
export CXXFLAGS="-I/opt/homebrew/include"
export LDFLAGS="-L/opt/homebrew/lib"
pip install jxlpy

Thank you. I was able to install jlxpy on my macOS 15.3 M2 Max machine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants