Skip to content

Commit

Permalink
Merge commit 'refs/integration/team/platform/merge-naoqi-libqi-302'
Browse files Browse the repository at this point in the history
  • Loading branch information
opennao committed Jun 18, 2021
2 parents 59e69ef + 59316e1 commit 3408a65
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 97 deletions.
93 changes: 50 additions & 43 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,30 @@
LibQiPython - LibQi Python bindings
===================================

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

__ LibQi_repo_

Building
========

This project supports the building of a "standalone" package (for instance as a
This project supports the building of a *standalone* package (for instance as a
wheel that can be uploaded on PyPi_) or of a "system" archive.

.. _standalone:

Standalone (wheel)
------------------

This build mode is also referred to as the "standalone" mode. It is enabled by
passing `-DQIPYTHON_STANDALONE=ON` to the CMake call. The Python setup script
This build mode is also referred to as the *standalone* mode. It is enabled by
passing ``-DQIPYTHON_STANDALONE=ON`` to the CMake call. The Python setup script
also sets this mode automatically when used.

In this mode, the project will build libqi and install all its dependencies as
part of the project.

The package can be built from the `setup.py` script:
The package can be built from the ``setup.py`` script:

.. code:: bash
Expand All @@ -42,7 +45,7 @@ handles any option the latter can handle. Additionally, it can take CMake
arguments, which means that you can almost entirely customize how the native
part is built.

In particular, you can use the `CMAKE_TOOLCHAIN_FILE` variable to specify a
In particular, you can use the ``CMAKE_TOOLCHAIN_FILE`` variable to specify a
toolchain to build the native part of the wheel (e.g. if you are using qi
toolchains):

Expand All @@ -65,13 +68,13 @@ first build libqi then libqi-python.
qibuild configure
qibuild make
You can also set the `QI_DIR` variable at the CMake call to let it know it of
You can also set the ``QI_DIR`` variable at the CMake call to let it know it of
the location of the libqi package.

.. code:: bash
mkdir build && cd build
cmake .. -DQI_DIR=<path to the libqi installation>
cmake .. -DQI_DIR=/path/to/libqi/install/dir
cmake --build .
Expand All @@ -84,76 +87,78 @@ least CMake v3.17.

Our CMake scripts may take a few parameters:

- `QIPYTHON_STANDALONE`, when set, builds the library in "standalone" mode.
- ``QIPYTHON_STANDALONE``, when set, builds the library in *standalone* mode.
Refer to the standalone_ section for details.
- `QIPYTHON_FORCE_STRIP`, when set, forces the build system to strip the
- ``QIPYTHON_FORCE_STRIP``, when set, forces the build system to strip the
libqi-python native module library at install, resulting in a smaller binary.
- `QI_WITH_TESTS`, when set, enables building of tests. This option is ignored
- ``QI_WITH_TESTS``, when set, enables building of tests. This option is ignored
when cross-compiling.

Dependencies
~~~~~~~~~~~~

The project has a few dependencies and the build system might report errors if
it fails to find them. It uses either `FindXXX` CMake modules through the
`find_package` command or the `FetchContent` module for subprojects. Either way,
any parameter that these modules and the `find_package` command accept can be
it fails to find them. It uses either ``FindXXX`` CMake modules through the
``find_package`` command or the ``FetchContent`` module for subprojects. Either way,
any parameter that these modules and the ``find_package`` command accept can be
used to customize how the build system finds the libraries or fetches the
subprojects.

Most of the variables described here are defined in the
`cmake/set_dependencies.cmake` file. You may refer to this file for more details
``cmake/set_dependencies.cmake`` file. You may refer to this file for more details
on these variables and their values.

LibQi
>>>>>

The project's dependencies on LibQi depends on the building mode:

- In system mode, it will expect to find it as a binary package. The location
of the binary package installation can be specified through the `QI_DIR`
- In **system mode**, it will expect to find it as a binary package. The location
of the binary package installation can be specified through the ``QI_DIR``
variable.
- In standalone mode, it will download and compile it as a subproject through
the `FetchContent` CMake module. How it is downloaded can be customized
- In **standalone mode**, it will download and compile it as a subproject through
the ``FetchContent`` CMake module. How it is downloaded can be customized
through the following variables:

- `LIBQI_VERSION`
- `LIBQI_GIT_REPOSITORY`
- `LIBQI_GIT_TAG`
- ``LIBQI_VERSION``
- ``LIBQI_GIT_REPOSITORY``
- ``LIBQI_GIT_TAG``

It is possible to skip the download step and use an existing source directory by
setting its path as the `FETCH_CONTENT_SOURCE_DIR_LIBQI` CMake variable. The
setting its path as the ``FETCHCONTENT_SOURCE_DIR_LIBQI`` CMake variable. The
build system will still check that the version of the sources matches the
`LIBQI_VERSION` value if it is set.
``LIBQI_VERSION`` value if it is set.

Python
>>>>>>

The build system uses the FindPython_ CMake module. It will try to honor the
following variables if they are set:

- `PYTHON_VERSION_STRING`
- `PYTHON_LIBRARY`
- `PYTHON_INCLUDE_DIR`
- ``PYTHON_VERSION_STRING``
- ``PYTHON_LIBRARY``
- ``PYTHON_INCLUDE_DIR``

pybind11
>>>>>>>>

The build system will by default download and compile pybind11_ as a
subproject through the `FetchContent` CMake module. How it is downloaded can be
The build system will by default download and compile pybind11__ as a
subproject through the ``FetchContent`` CMake module. How it is downloaded can be
customized through the following variables:

- `PYBIND11_VERSION`
- `PYBIND11_GIT_REPOSITORY`
- `PYBIND11_GIT_TAG`
__ pybind11_repo_

- ``PYBIND11_VERSION``
- ``PYBIND11_GIT_REPOSITORY``
- ``PYBIND11_GIT_TAG``


Boost
>>>>>

The build system will look for the Boost libraries on the system or in the
toolchain if one is set. The expected version of the libraries is specified as
the `BOOST_VERSION` variable.
the ``BOOST_VERSION`` variable.

The build system uses the FindBoost_ CMake module.

Expand All @@ -170,13 +175,15 @@ The build system uses the FindICU_ CMake module.
GoogleTest
>>>>>>>>>>

The build system will by default download and compile GoogleTest_ as a
subproject through the `FetchContent` CMake module. How it is downloaded can be
The build system will by default download and compile GoogleTest__ as a
subproject through the ``FetchContent`` CMake module. How it is downloaded can be
customized through the following variables:

- `GOOGLETEST_VERSION`
- `GOOGLETEST_GIT_REPOSITORY`
- `GOOGLETEST_GIT_TAG`
__ GoogleTest_repo_

- ``GOOGLETEST_VERSION``
- ``GOOGLETEST_GIT_REPOSITORY``
- ``GOOGLETEST_GIT_TAG``

Install
~~~~~~~
Expand All @@ -195,7 +202,7 @@ 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
toolchains`__. You may simply set the ``CMAKE_TOOLCHAIN_FILE`` variable to the
path of the CMake file in your toolchain.

__ CMake_toolchains_
Expand All @@ -210,16 +217,16 @@ When enabled, tests can be executed with `CTest`_.
cd build
ctest . --output-on-failure
.. _LibQi: https://github.com/aldebaran/libqi
.. _LibQi_repo: https://github.com/aldebaran/libqi
.. _PyPi: https://pypi.org/
.. _scikit-build: https://scikit-build.readthedocs.io/en/latest/
.. _setuptools: https://setuptools.readthedocs.io/en/latest/setuptools.html
.. _qibuild: https://github.com/aldebaran/qibuild
.. _pybind11: https://pybind11.readthedocs.io/en/latest/
.. _pybind11_repo: https://pybind11.readthedocs.io/en/latest/
.. _FindPython: https://cmake.org/cmake/help/latest/module/FindPython.html
.. _FindBoost: https://cmake.org/cmake/help/latest/module/FindBoost.html
.. _FindOpenSSL: https://cmake.org/cmake/help/latest/module/FindOpenSSL.html
.. _FindICU: https://cmake.org/cmake/help/latest/module/FindICU.html
.. _GoogleTest: https://github.com/google/googletest
.. _GoogleTest_repo: https://github.com/google/googletest
.. _CMake_toolchains: https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html
.. _CTest: https://cmake.org/cmake/help/latest/manual/ctest.1.html
.. _CTest: https://cmake.org/cmake/help/latest/manual/ctest.1.html
60 changes: 24 additions & 36 deletions cmake/set_dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -44,42 +44,30 @@

include_guard(GLOBAL)

set(BOOST_VERSION 1.64
CACHE STRING
"Version of Boost to use. It will be used as the argument to the
`find_package(Boost)` call.")

set(PYBIND11_VERSION 2.5.0
CACHE STRING
"Version of pybind11 to use.")

set(PYBIND11_GIT_REPOSITORY https://github.com/pybind/pybind11
CACHE STRING
"URL of the git repository from which to download pybind11. For more \
details, see CMake `ExternalProject` module documentation of the \
`GIT_REPOSITORY` argument.")

set(PYBIND11_GIT_TAG v${PYBIND11_VERSION}
CACHE STRING
"Git branch name, tag or commit hash to checkout for pybind11. \
For more details, see CMake `ExternalProject` module documentation of the \
`GIT_TAG` argument.")

set(GOOGLETEST_VERSION 1.10.0
CACHE STRING
"Version of googletest to use.")

set(GOOGLETEST_GIT_REPOSITORY https://github.com/google/googletest.git
CACHE STRING
"URL of the git repository from which to download googletest. For more \
details, see CMake `ExternalProject` module documentation of the \
`GIT_REPOSITORY` argument.")

set(GOOGLETEST_GIT_TAG release-${GOOGLETEST_VERSION}
CACHE STRING
"Git branch name, tag or commit hash to checkout for googletest. \
For more details, see CMake `ExternalProject` module documentation of the \
`GIT_TAG` argument.")
# Version of Boost to use. It will be used as the argument to the `find_package(Boost)` call.
overridable_variable(BOOST_VERSION 1.64)

# Version of pybind11 to use.
overridable_variable(PYBIND11_VERSION 2.5.0)

# URL of the git repository from which to download pybind11. For more details, see CMake
# `ExternalProject` module documentation of the `GIT_REPOSITORY` argument.
overridable_variable(PYBIND11_GIT_REPOSITORY https://github.com/pybind/pybind11)

# Git branch name, tag or commit hash to checkout for pybind11. For more details, see CMake
# `ExternalProject` module documentation of the `GIT_TAG` argument.
overridable_variable(PYBIND11_GIT_TAG v${PYBIND11_VERSION})

# Version of googletest to use.
overridable_variable(GOOGLETEST_VERSION 1.10.0)

# URL of the git repository from which to download googletest. For more details, see CMake
# `ExternalProject` module documentation of the `GIT_REPOSITORY` argument.
overridable_variable(GOOGLETEST_GIT_REPOSITORY https://github.com/google/googletest.git)

# Git branch name, tag or commit hash to checkout for googletest. For more details, see CMake
# `ExternalProject` module documentation of the `GIT_TAG` argument.
overridable_variable(GOOGLETEST_GIT_TAG release-${GOOGLETEST_VERSION})

set(PYTHON_VERSION_STRING "" CACHE STRING "Version of Python to look for. This \
variable can be specified by tools run directly from Python to enforce the \
Expand Down
18 changes: 3 additions & 15 deletions cmake/set_libqi_dependency.cmake
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
set(LIBQI_VERSION 1.8.6
CACHE STRING
"Version of LibQi to use. If not empty, it will be checked against the \
version in the `package.xml` file in the libqi sources.")
overridable_variable(LIBQI_VERSION 1.8.7)

# Our github clone is sometimes late or is missing tags, so we enable
# customisation of the URL at configuration time, so users can use another clone.
set(LIBQI_GIT_REPOSITORY https://github.com/aldebaran/libqi.git
CACHE STRING
"URL of the git repository from which to download LibQi. For more details, \
see CMake `ExternalProject` module documentation of the `GIT_REPOSITORY` \
argument.")

set(LIBQI_GIT_TAG qi-framework-v${LIBQI_VERSION}
CACHE STRING
"Git branch name, tag or commit hash to checkout for LibQi. \
For more details, see CMake `ExternalProject` module documentation of the \
`GIT_TAG` argument.")
overridable_variable(LIBQI_GIT_REPOSITORY https://github.com/aldebaran/libqi.git)

overridable_variable(LIBQI_GIT_TAG qi-framework-v${LIBQI_VERSION})

if(LIBQI_VERSION)
message(STATUS "LibQi: expected version is \"${LIBQI_VERSION}\"")
Expand Down
21 changes: 21 additions & 0 deletions cmake/utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,24 @@ function(set_install_rpath)
endif()
endforeach()
endfunction()

# Creates a variable that can be overridden by the user from either the
# command-line, the cache or the environment.
# The order of preference is:
# - the value from the variable in cache (or the command-line, since setting
# a variable from the command-line automatically adds it to the cache).
# - the value from the variable in the environment.
# - the default value for the variable.
function(overridable_variable name default_value)
# The variable already exists in the cache. It's the preferred value, so we
# don't change it.
if(DEFINED CACHE{${name}})
return()
endif()

set(value ${default_value})
if(DEFINED ENV{${name}})
set(value $ENV{${name}})
endif()
set(${name} ${value} PARENT_SCOPE)
endfunction()
2 changes: 1 addition & 1 deletion qi/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '2.0.1'
__version__ = '2.0.2'
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
version=version['__version__'],
description='LibQi Python bindings',
long_description=long_description,
long_description_content_type='text/markdown',
long_description_content_type='text/x-rst',
keywords=['libqi', 'qi', 'naoqi',
'softbank', 'robotics', 'aldebaran',
'robot', 'nao', 'pepper', 'romeo'],
Expand Down
2 changes: 1 addition & 1 deletion tests/moduletest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ std::string Cat::meow(int volume)
return "meow";
}

bool Cat::eat(const Mouse& m)
bool Cat::eat(const Mouse&)
{
qiLogInfo() << "eating mouse";
return true;
Expand Down

0 comments on commit 3408a65

Please sign in to comment.