Package: qi
This repository contains the official Python bindings of theLibQi, theqiPython module.BuildingTo build the project, you need:a compiler that supports C++17.on Ubuntu:apt-get install build-essential.CMake with at least version 3.23.on PyPI (recommended):pip install “cmake>=3.23”.on Ubuntu:apt-get install cmake.Python with at least version 3.7 and its development libraries.On Ubuntu:apt-get install libpython3-dev.a Pythonvirtualenv.On Ubuntu:apt-get install python3-venv
python3 -m venv ~/my-venv # Use the path of your convenience.
source ~/my-venv/bin/activateNoteThe CMake project offers several configuration options and exports a set
of targets when installed. You may refer to theCMakeLists.txtfile
for more details about available parameters and exported targets.NoteThe procedures described below assume that you have downloaded the project
sources, that your current working directory is the project sources root
directory and that you are working inside your virtualenv.ConanAdditionally,libqi-pythonis available as a Conan 2 project, which means you
can use Conan to fetch dependencies.You can install and/or upgrade Conan 2 and create a default profile in the
following way:#install/upgradeConan2pip install --upgrade conan~=2#createadefaultprofileconan profile detectInstall dependencies from Conan and build with CMakeThe procedure to build the project using Conan to fetch dependencies is the
following.Most dependencies are available on Conan Center repository and should not
require any additional steps to make them available. However, you might need to
first get and export thelibqirecipe into your local Conan cache.#GitHubisavailable,butyoucanalsouseinternalGitLab.QI_REPOSITORY="https://github.com/aldebaran/libqi.git"
QI_VERSION="4.0.1" # Checkout the version your project need.
QI_PATH="$HOME/libqi" # Or whatever path you want.
git clone \
  --depth=1 `# Only fetch one commit.` \
  --branch "qi-framework-v${QI_VERSION}" \
  "${QI_REPOSITORY}" \
  "${QI_PATH}"
conan export "${QI_PATH}" \
  --version "${QI_VERSION}" # Technically not required but some#versionsoflibqirequireit#becauseofabug.You can then install thelibqi-pythondependencies in Conan.conan install . \
  --build=missing `# Build dependencies binaries that are missing in Conan.` \
  -s build_type=Debug `# Build in debug mode.` \
  -c tools.build:skip_test=true `# Skip tests building for dependencies.` \
  -c '&:tools.build:skip_test=false' # Do not skip tests for the project.This will generate a build directory containing a configuration with a
toolchain file that allows CMake to find dependencies inside the Conan cache.You can then invoke CMake directly inside the build configuration directory to
configure and build the project. Fortunately, Conan also generates a CMake
preset that simplifies the process. The name of the preset may differ on
your machine. You may need to find the preset generated by Conan first by
calling:cmake --list-presetsHere, we’ll assume that the preset is namedconan-linux-x86_64-gcc-debug.
To start building, you need to configure with CMake and then build:cmake --preset conan-linux-x86_64-gcc-debug
cmake --build --preset conan-linux-x86_64-gcc-debugTests can now be invoked usingCTest, but they require a runtime environment
from Conan so that all dependencies are found:source build/linux-x86_64-gcc-debug/generators/conanrun.sh
ctest --preset conan-linux-x86_64-gcc-debug --output-on-failure
source build/linux-x86_64-gcc-debug/generators/deactivate_conanrun.shFinally, you can install the project in the directory of your choice.The project defines a single install component, theModulecomponent.#`cmake--install`doesnotsupportpresetssadly.cmake \
  --install build/linux-x86_64-gcc-debug \
  --component Module --prefix ~/my-libqi-python-installWheel (PEP 517)You may build this project as a wheel package using PEP 517.It uses ascikit-buildbackend which interfaces with CMake.You may need to provide a toolchain file so that CMake finds the required
dependencies, such as a toolchain generated by Conan:conan install . \
  --build=missing `# Build dependencies binaries that are missing in Conan.` \
  -c tools.build:skip_test=true # Skip any test.You now can use thebuildPython module to build the wheel using PEP 517.pip install -U build
python -m build \
  --config-setting cmake.define.CMAKE_TOOLCHAIN_FILE=$PWD/build/linux-x86_64-gcc-release/generators/conan_toolchain.cmakeWhen built that way, the native libraries present in the wheel are most likely incomplete.
You will need to useauditwheelordelocateto fix it.Noteauditwheelrequires thepatchelfutility program on Linux. You may need
to install it (on Ubuntu:apt-get install patchelf).pip install -U auditwheel # or `delocate` on MacOS.
auditwheel repair \
  --strip `# Strip debugging symbols to get a lighter archive.` \
  `# The desired platform, which may differ depending on your build host.` \
  `# With Ubuntu 20.04, we can target manylinux_2_31. Newer versions of` \
  `# Ubuntu will have to target newer versions of manylinux.` \
  `# If you don't need a manylinux archive, you can also target the` \
  `# 'linux_x86_64' platform.` \
  --plat manylinux_2_31_x86_64 \
  `# Path to the wheel archive.` \
  dist/qi-*.whl#Thewheelwillbebydefaultplacedina`./wheelhouse/`directory.CrosscompilingThe project supports cross-compiling as explained in theCMake manual about
toolchains. You may simply set theCMAKE_TOOLCHAIN_FILEvariable to the
path of the CMake file of your toolchain.