0

I am trying to install a package from PyPi upolygon on my Buildroot based aarch64 GNU/Linux embedded device. But while installing pip is creating the wheel (.whl) file for the package. Since there is no compiler on the target (Buildroot will not include any compiler in the target image), building wheel for upolygon is failing.

pip install upolygon --no-cache-dir

Building wheels for collected packages: upolygon
  Building wheel for upolygon (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for upolygon (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [13 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.linux-aarch64-cpython-310
      creating build/lib.linux-aarch64-cpython-310/upolygon
      copying upolygon/__init__.py -> build/lib.linux-aarch64-cpython-310/upolygon
      running build_ext
      building 'draw_polygon' extension
      creating build/temp.linux-aarch64-cpython-310
      creating build/temp.linux-aarch64-cpython-310/upolygon
      /home/buildroot/../per-package/python3/host/bin/aarch64-linux-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -O3 -Wall -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -O3 -g0 -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.10 -c upolygon/draw_polygon.c -o build/temp.linux-aarch64-cpython-310/upolygon/draw_polygon.o -O3 -Wall
      error: command '/home/buildroot/../per-package/python3/host/bin/aarch64-linux-gcc' failed: No such file or directory
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for upolygon
Failed to build upolygon
ERROR: Could not build wheels for upolygon, which is required to install pyproject.toml-based projects

python3 version: Python 3.10.4

pip3 version: pip 23.2.1

Can anyone please let me know how I can disable pip from building wheel for the package?

P.S: please let me know if any info is missing

Preeti
  • 535
  • 1
  • 6
  • 30
  • 1
    It needs to build the package because it needs the native libs. It just puts the output in the wheel. If you don't want to build it, then you need to find one that is already built for your platform. eg maybe a upolygon exists for your platform with a different python version? – matt Aug 17 '23 at 09:52
  • Hello @matt, thanks for the update. I couldn't find uploygon package for aarch64. It's only for `x86_64` and `i686` architectures. Do you know how I can create the whhel for aarch64 from my host machine. I have the compiler `aarch64-linux-gcc` on my host and can I use this to cross-compile the required package from source?https://files.pythonhosted.org/packages/4f/f7/b2010ab6d092e190d0411f807d9a5c4b6f4e7e4734791ea09f1821075c10/upolygon-0.1.11.tar.gz – Preeti Aug 17 '23 at 10:03
  • I was looking, and I don't see an easy way. You'll need a version of aarch64 python on your host system to compile against. There is also an emulator like qemu. You can mirror the environment you want and then build it. Then you just download the source code and run. `python setup.py bdist_wheel` and it will target the platform your using. – matt Aug 17 '23 at 10:18
  • Hello @matt, I tried `python setup.py bdist_wheel` with my host python3 (not aarch64, x86_64 GNU/Linux) and I have set env variables `CC, CXX, AR`, but it showed `invalid command 'bdist_wheel'`, updated `setuptools` but still same error. Then tried with `python setup.py bdist` no error occured, but no wheels created in `dist` dir. only `.tar.gz` created. I thought this setting was enough and no special python is required... – Preeti Aug 17 '23 at 10:31
  • If you do it on your x86 machine it will target x86. You need to install `wheel` if you want to create a wheel. What I mean is, if you start an emulator you can use python setup.py. I am not sure what you need to do to cross compile. – matt Aug 17 '23 at 10:35
  • 1
    https://cibuildwheel.readthedocs.io/en/stable/faq/#emulation – matt Aug 17 '23 at 10:35
  • That has some information about cross compiling. – matt Aug 17 '23 at 10:36
  • Hello @matt, I am trying to build wheel as described here https://github.com/ARM-software/developer/blob/master/projects/python-wheels/multi-platform.md#run-a-aarch64-native-container-on-x86-with-emulation (with https://quay.io/repository/pypa/manylinux2014_aarch64 conatiner) and QEMU (https://github.com/multiarch/qemu-user-static). What i am doing: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes docker run --rm -v `pwd`:/io quay.io/pypa/manylinux2014_aarch64 bash -c '/opt/python/cp38-cp38/bin/python ./setup.py bdist_wheel' – Preeti Aug 19 '23 at 07:59
  • But it says: WARNING: The requested image's platform (linux/arm64/v8) does not match the detected host platform (linux/amd64/v4) and no specific platform was requested How should I pass qemu-aarch64-static to above docker command? I am working with WSL2 – Preeti Aug 19 '23 at 08:04
  • 1
    You might want to ask another question, with these specifics. Something along the lines of "how do I compile a python package for aarch64 using qemu" Then show what you've done. Then include docker in the tags. It seems like a good question, but might be a bit hidden in this one. – matt Aug 21 '23 at 06:44
  • Hi @matt, I have asked separate OP https://stackoverflow.com/questions/76944114/how-to-compile-and-build-a-python-package-for-aarch64-using-qemu – Preeti Aug 21 '23 at 09:43
  • Hi @matt, do you think can I cross-compile with Buildroot SDK? I have the SDK for target. – Preeti Aug 21 '23 at 15:38

0 Answers0