chaquo / chaquopy

Chaquopy: the Python SDK for Android
https://chaquo.com/chaquopy/
MIT License
830 stars 131 forks source link

AprilTag: Wheel File Generation (build-wheel.py error) #1263

Open drphipi opened 2 weeks ago

drphipi commented 2 weeks ago

I am attempting to generate a wheel file for the apriltag library so that I can import it for future use in a mobile application.

Setup: Host OS: Windows 11 VirtualBox: Linux Mint Xfce

Error:

-- The C compiler identification is Clang 11.0.5
-- The CXX compiler identification is Clang 11.0.5
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /home/username/Downloads/android-sdk/ndk/22.1.7171670/toolchains/llvm/prebuilt/linux-x86_64/bin/clang - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /home/username/Downloads/android-sdk/ndk/22.1.7171670/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Deprecation Warning at CMakeLists.txt:3 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - not found
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE  
-- Found PkgConfig: /home/username/Downloads/chaquopy/server/pypi/env/bin/pkg-config (found version "1.8.1") 
-- Checking for one of the modules 'opencv>=2.3;opencv-2.3.1;opencv-3.0.0'
-- Configuring done (2.2s)
-- Generating done (0.0s)
-- Build files have been written to: /home/username/Downloads/chaquopy/server/pypi/packages/apriltag/build/0.0.16/cp38-cp38-android_24_arm64_v8a/src/build
++ nproc
+ make -j4
[  2%] Building C object core/CMakeFiles/apriltag.dir/apriltag.c.o
[  4%] Building C object core/CMakeFiles/apriltag.dir/apriltag_quad_thresh.c.o
[  6%] Building C object core/CMakeFiles/apriltag.dir/tag16h5.c.o
[  8%] Building C object core/CMakeFiles/apriltag.dir/tag25h7.c.o
clangclang: error: the clang compiler does not support '-march=native'
: error: the clang compiler does not support '-march=native'
make[2]: *** [core/CMakeFiles/apriltag.dir/build.make:76: core/CMakeFiles/apriltag.dir/apriltag.c.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: *** [core/CMakeFiles/apriltag.dir/build.make:90: core/CMakeFiles/apriltag.dir/apriltag_quad_thresh.c.o] Error 1
clang: error: the clang compiler does not support '-march=native'
make[2]: *** [core/CMakeFiles/apriltag.dir/build.make:118: core/CMakeFiles/apriltag.dir/tag25h7.c.o] Error 1
clang: error: the clang compiler does not support '-march=native'
make[2]: *** [core/CMakeFiles/apriltag.dir/build.make:104: core/CMakeFiles/apriltag.dir/tag16h5.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:110: core/CMakeFiles/apriltag.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
build-wheel: Error: Command '. /home/username/Downloads/chaquopy/server/pypi/packages/apriltag/build/0.0.16/cp38-cp38-android_24_arm64_v8a/env/bin/activate; /home/username/Downloads/chaquopy/server/pypi/packages/apriltag/build.sh' returned non-zero exit status 2.

Configuration: How to exactly replicate the error (these are all the terminal commands, in order, that were run from when the virtual machine was made to the point where the error was encountered):

#!/bin/bash

sudo apt update
sudo apt install -y git

# Navigate to the Downloads folder
cd ~/Downloads

# Clone the Chaquopy repository
git clone https://github.com/chaquo/chaquopy.git

# Change directory to the cloned repository
cd chaquopy

# Execute the target/download-target.sh script with the specified argument
./target/download-target.sh maven/com/chaquo/python/target/3.8.16-0

# Download the Miniconda installer
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh

bash Miniconda3-latest-Linux-x86_64.sh

# Add Conda to PATH
export PATH="$HOME/miniconda3/bin:$PATH"

conda init

conda create -n build-wheel python=3.8 -y

source activate base

conda activate build-wheel

# Download Android command line tools
wget https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip

# Create directory for Android SDK command line tools
mkdir -p ~/Downloads/android-sdk/cmdline-tools

# Unzip the command line tools package into the created directory
unzip commandlinetools-linux-11076708_latest.zip -d ~/Downloads/android-sdk/cmdline-tools

# Rename directory
mv ~/Downloads/android-sdk/cmdline-tools/cmdline-tools ~/Downloads/android-sdk/cmdline-tools/latest

# Export ANDROID_HOME environment variable
export ANDROID_HOME="$HOME/Downloads/android-sdk"

# Go to chaquopy/server/pypi and install requirements
cd ~/Downloads/chaquopy/server/pypi

pip install -r requirements.txt

sudo apt install -y patch patchelf

# Install OpenJDK 17 JDK
sudo apt install openjdk-17-jdk -y

# Set JAVA_HOME to the new Java installation
export JAVA_HOME="/usr/lib/jvm/java-17-openjdk-amd64"

# Install CMake
sudo apt install cmake -y

# Navigate to the specified directory
cd ~/Downloads/chaquopy/server/pypi/packages

mkdir -p "apriltag"

# Create the meta.yaml file with the specified content
cat <<EOL > "apriltag/meta.yaml"
package:
  name: apriltag
  version: "0.0.16"
EOL

# Navigate back to the pypi directory
cd ~/Downloads/chaquopy/server/pypi

# Run the build-wheel.py script with specified arguments
./build-wheel.py --python 3.8 --abi arm64-v8a "apriltag"
drphipi commented 2 weeks ago

Also tried with an Ubuntu VM, same error

drphipi commented 1 week ago

I ran this exact same setup, but instead of building apriltag I built multidict. In other words, I ran ./build-wheel.py --python 3.8 --abi arm64-v8a "multidict" instead of ./build-wheel.py --python 3.8 --abi arm64-v8a "apriltag" Just to make sure that my setup is OK, and I was able to successfully build the wheel file. 🥳 This makes me think that whatever difficulties I am having in generating the wheel file for the apriltag package is related to the package itself, and not related to my setup.

mhsmith commented 1 week ago

Thanks for the detailed report, and sorry for the slow reply.

This error has already been reported in the package's issue tracker at https://github.com/swatbotics/apriltag/issues/28, and it looks like there's a simple workaround. To try it, see "If any changes are needed to make the build work" in the README.