Skip to content

Python Bindings

Some functionality of B-Human is exported to Python using pybind11 in a package called pybh.

Installation (only for B-Human members)

The GitLab CI builds and uploads the package when triggered manually (the version number in Make/Python/setup.py should be incremented before). There is a binary wheel for x86_64-Linux with CPython 3.10 and a source distribution for all other platforms. pip and other Python package managers automatically choose the right thing when being instructed to install pybh.

Requirements

  • A GitLab access token (with read_api permissions) is required. This can be either a personal token or a group token (the latter can not be created with regular permissions).
  • If the Python environment is not CPython 3.10 on x86_64-Linux, build tools (i.e. a compiler etc.) must be available. On Linux, at least clang, ccache and mold must be available (the latter can be symlinked to ld if mold is not available).

Procedure

  1. While the Python environment in which you want to install the package is active, run:
    pip install pybh --index-url https://__token__:<the-access-token>@gitlab.informatik.uni-bremen.de/api/v4/projects/7408/packages/pypi/simple
    

Of course, the package index can be used with other Python package managers, too. The details of that are beyond the scope of this page.

Local Build

There are different methods to build the package without downloading anything from the GitLab package registry, among them:

  1. Creating a distribution locally using build (and installing it). This is best done by looking at /.gitlab-ci.yml in the B-Human repository, but does not work on Windows because it relies on symbolic links.
  2. Building the targets directly in the CMake project. This requires Python development files (libraries and headers) to be found during project generation. Then, the targets Python* can be build like any other target.
  3. Installing the source directory via pip. This is described below.

Requirements

  • Linux or macOS. Windows does not work because symbolic links are required.
  • The usual platform-dependent dependencies as given in Getting Started
  • pip >= 21.3 (or --use-feature=in-tree-build must be used)

Procedure

  1. Ensure that Make/Python/build and Make/Python/pybh.egg-info do not exist (these may be left from previous builds).
  2. While the Python environment in which you want to install the package is active, run:
    pip install <path-to-B-Human>/Make/Python
    

API

See the B-Human Python documentation.


Last update: October 14, 2023