Skip to main content

LibQi Python bindings

Project description

This repository contains the official Python bindings of the LibQi, the qi Python module.

Building

To 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 Python virtualenv.

    • On Ubuntu:

      apt-get install python3-venv
      python3 -m venv ~/my-venv # Use the path of your convenience.
      source ~/my-venv/bin/activate

Conan

Additionally, libqi-python is 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/upgrade Conan 2
pip install --upgrade conan~=2
# create a default profile
conan profile detect

Install dependencies from Conan and build with CMake

The 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 the libqi recipe into your local Conan cache.

# GitHub is available, but you can also use internal GitLab.
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
                            # versions of libqi require it
                            # because of a bug.

You can then install the libqi-python dependencies 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-presets

Here, we’ll assume that the preset is named conan-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-debug

Tests can now be invoked using CTest, 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.sh

Finally, you can install the project in the directory of your choice.

The project defines a single install component, the Module component.

# `cmake --install` does not support presets sadly.
cmake \
  --install build/linux-x86_64-gcc-debug \
  --component Module --prefix ~/my-libqi-python-install

Wheel (PEP 517)

You may build this project as a wheel package using PEP 517.

It uses a scikit-build backend 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 the build Python 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.cmake

When built that way, the native libraries present in the wheel are most likely incomplete. You will need to use auditwheel or delocate to fix it.

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
# The wheel will be by default placed in a `./wheelhouse/` directory.

Crosscompiling

The project supports cross-compiling as explained in the CMake manual about toolchains. You may simply set the CMAKE_TOOLCHAIN_FILE variable to the path of the CMake file of your toolchain.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

qi-3.1.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.4 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

qi-3.1.5-cp312-cp312-macosx_13_0_arm64.whl (6.7 MB view hashes)

Uploaded CPython 3.12 macOS 13.0+ ARM64

qi-3.1.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.4 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

qi-3.1.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.4 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

qi-3.1.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.4 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

qi-3.1.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.4 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

qi-3.1.5-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.4 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page