@@ -10,9 +10,30 @@ __ LibQi_repo_
1010Building
1111========
1212
13- The libqi-python project requires a compiler that supports C++17 to build.
13+ To build the project, you need:
1414
15- It is built with CMake >= 3.23.
15+ - a compiler that supports C++17.
16+
17+ - on Ubuntu: `apt-get install build-essential `.
18+
19+ - CMake with at least version 3.23.
20+
21+ - on PyPI (**recommended **): `pip install "cmake>=3.23" `.
22+ - on Ubuntu: `apt-get install cmake `.
23+
24+ - Python with at least version 3.7 and its development libraries.
25+
26+ - On Ubuntu: `apt-get install libpython3-dev `.
27+
28+ - a Python `virtualenv `.
29+
30+ - On Ubuntu:
31+
32+ .. code-block :: console
33+
34+ apt-get install python3-venv
35+ python3 -m venv ~/my-venv # Use the path of your convenience.
36+ source ~/my-venv/bin/activate
1637
1738 .. note ::
1839 The CMake project offers several configuration options and exports a set
@@ -21,13 +42,13 @@ It is built with CMake >= 3.23.
2142
2243.. note ::
2344 The procedures described below assume that you have downloaded the project
24- sources and that your current working directory is the project sources root
25- directory.
45+ sources, that your current working directory is the project sources root
46+ directory and that you are working inside your virtualenv .
2647
2748Conan
2849^^^^^
2950
30- Additionally, libqi-python is available as a Conan 2 project, which means you
51+ Additionally, ` libqi-python ` is available as a Conan 2 project, which means you
3152can use Conan to fetch dependencies.
3253
3354You can install and/or upgrade Conan 2 and create a default profile in the
@@ -46,11 +67,35 @@ Install dependencies from Conan and build with CMake
4667The procedure to build the project using Conan to fetch dependencies is the
4768following.
4869
49- You must first install the project dependencies in Conan.
70+ Most dependencies are available on Conan Center repository and should not
71+ require any additional steps to make them available. However, you might need to
72+ first get and export the `libqi ` recipe into your local Conan cache.
5073
5174.. code-block :: console
5275
53- conan install . --build=missing -s build_type=Debug
76+ # GitHub is available, but you can also use internal GitLab.
77+ QI_REPOSITORY="https://github.com/aldebaran/libqi.git"
78+ QI_VERSION="4.0.1" # Checkout the version your project need.
79+ QI_PATH="$HOME/libqi" # Or whatever path you want.
80+ git clone \
81+ --depth=1 `# Only fetch one commit.` \
82+ --branch "qi-framework-v${QI_VERSION}" \
83+ "${QI_REPOSITORY}" \
84+ "${QI_PATH}"
85+ conan export "${QI_PATH}" \
86+ --version "${QI_VERSION}" # Technically not required but some
87+ # versions of libqi require it
88+ # because of a bug.
89+
90+ You can then install the `libqi-python ` dependencies in Conan.
91+
92+ .. code-block :: console
93+
94+ conan install . \
95+ --build=missing `# Build dependencies binaries that are missing in Conan.` \
96+ -s build_type=Debug `# Build in debug mode.` \
97+ -c tools.build:skip_test=true `# Skip tests building for dependencies.` \
98+ -c '&:tools.build:skip_test=false' # Do not skip tests for the project.
5499
55100 This will generate a build directory containing a configuration with a
56101toolchain file that allows CMake to find dependencies inside the Conan cache.
@@ -73,20 +118,24 @@ To start building, you need to configure with CMake and then build:
73118 cmake --preset conan-linux-x86_64-gcc-debug
74119 cmake --build --preset conan-linux-x86_64-gcc-debug
75120
76- You can then invoke tests using CTest _:
121+ Tests can now be invoked using CTest _, but they require a runtime environment
122+ from Conan so that all dependencies are found:
77123
78124.. code-block :: console
79125
126+ source build/linux-x86_64-gcc-debug/generators/conanrun.sh
80127 ctest --preset conan-linux-x86_64-gcc-debug --output-on-failure
128+ source build/linux-x86_64-gcc-debug/generators/deactivate_conanrun.sh
81129
82130 Finally, you can install the project in the directory of your choice.
83131
84132The project defines a single install component, the ``Module `` component.
85133
86134.. code-block :: console
87135
88- # "cmake --install" does not support preset sadly.
89- cmake --install build/linux-x86_64-gcc-debug
136+ # `cmake --install` does not support presets sadly.
137+ cmake \
138+ --install build/linux-x86_64-gcc-debug \
90139 --component Module --prefix ~/my-libqi-python-install
91140
92141 Wheel (PEP 517)
@@ -101,34 +150,50 @@ dependencies, such as a toolchain generated by Conan:
101150
102151.. code-block :: console
103152
104- conan install . --build=missing
153+ conan install . \
154+ --build=missing `# Build dependencies binaries that are missing in Conan.` \
155+ -c tools.build:skip_test=true # Skip any test.
105156
106157 You now can use the ``build `` Python module to build the wheel using PEP 517.
107158
108159.. code-block :: console
109160
110- export CMAKE_TOOLCHAIN_FILE=$PWD/build/linux-x86_64-gcc-release/generators/conan_toolchain.cmake
111- python -m build
161+ pip install -U build
162+ python -m build \
163+ --config-setting cmake.define.CMAKE_TOOLCHAIN_FILE=$PWD/build/linux-x86_64-gcc-release/generators/conan_toolchain.cmake
112164
113165 When built that way, the native libraries present in the wheel are most likely incomplete.
114166You will need to use ``auditwheel `` or ``delocate `` to fix it.
115167
168+ .. note ::
169+ `auditwheel ` requires the `patchelf ` utility program on Linux. You may need
170+ to install it (on Ubuntu: `apt-get install patchelf `).
171+
116172.. code-block :: console
117173
118- auditwheel repair --plat manylinux_2_31_x86_64 dist/qi-*.whl
174+ pip install -U auditwheel # or `delocate` on MacOS.
175+ auditwheel repair \
176+ --strip `# Strip debugging symbols to get a lighter archive.` \
177+ `# The desired platform, which may differ depending on your build host.` \
178+ `# With Ubuntu 20.04, we can target manylinux_2_31. Newer versions of` \
179+ `# Ubuntu will have to target newer versions of manylinux.` \
180+ `# If you don't need a manylinux archive, you can also target the` \
181+ `# 'linux_x86_64' platform.` \
182+ --plat manylinux_2_31_x86_64 \
183+ `# Path to the wheel archive.` \
184+ dist/qi-*.whl
119185 # The wheel will be by default placed in a `./wheelhouse/` directory.
120186
121187 Crosscompiling
122188--------------
123189
124190The project supports cross-compiling as explained in the `CMake manual about
125191toolchains `__. You may simply set the ``CMAKE_TOOLCHAIN_FILE `` variable to the
126- path of the CMake file in your toolchain.
192+ path of the CMake file of your toolchain.
127193
128194__ CMake_toolchains _
129195
130196.. _LibQi_repo : https://github.com/aldebaran/libqi
131197.. _scikit-build : https://scikit-build.readthedocs.io/en/latest/
132- .. _setuptools : https://setuptools.readthedocs.io/en/latest/setuptools.html
133198.. _CMake_toolchains : https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html
134199.. _CTest : https://cmake.org/cmake/help/latest/manual/ctest.1.html
0 commit comments