From 96446ccf891938f88b6a0ec01517e459c29a6731 Mon Sep 17 00:00:00 2001 From: thervier Date: Tue, 29 Apr 2025 21:04:43 +0200 Subject: [PATCH 01/12] Remove gitlab-ci (not used) --- .gitlab-ci.yml | 53 -------------------------------------------------- 1 file changed, 53 deletions(-) delete mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index be06278..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,53 +0,0 @@ -stages: - - build - - publish - - release - -.if-tag: &if-tag - if: "$CI_COMMIT_TAG =~ /^qi-python-v/" - -build-wheel: - stage: build - rules: - # Allow manually building on a Git commit on any branch. - - if: $CI_COMMIT_BRANCH - when: manual - # Always build on a Git tag. - - <<: *if-tag - tags: - - docker - image: python:3.8 - script: - - curl -sSL https://get.docker.com/ | sh - - pip install cibuildwheel==2.14.1 - - cibuildwheel --output-dir wheelhouse - artifacts: - paths: - - wheelhouse/ - -publish-wheel: - stage: publish - image: python:latest - rules: - - <<: *if-tag - needs: - - build-wheel - script: - - pip install build twine - - python -m build - - TWINE_PASSWORD="${CI_JOB_TOKEN}" - TWINE_USERNAME=gitlab-ci-token - python -m twine upload - --repository-url "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi" - wheelhouse/* - -create-release: - stage: release - rules: - - <<: *if-tag - script: - - echo "Releasing $CI_COMMIT_TAG." - release: - tag_name: $CI_COMMIT_TAG - name: 'lib$CI_COMMIT_TITLE' - description: '$CI_COMMIT_TAG_MESSAGE' From c2a9634bb6ab4b8fe5932ee13509ca5e4b896bec Mon Sep 17 00:00:00 2001 From: thervier Date: Tue, 29 Apr 2025 21:04:57 +0200 Subject: [PATCH 02/12] qipython: fix for compatibility with CPython 3.13+ --- qipython/common.hpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/qipython/common.hpp b/qipython/common.hpp index 3335f66..0836b2e 100644 --- a/qipython/common.hpp +++ b/qipython/common.hpp @@ -116,8 +116,11 @@ boost::optional extractKeywordArg(pybind11::dict kwargs, /// finalizing or not. inline boost::optional interpreterIsFinalizing() { -// `_Py_IsFinalizing` is only available on CPython 3.7+ -#if PY_VERSION_HEX >= 0x03070000 +// `Py_IsFinalizing` is only available on CPython 3.13+ +#if PY_VERSION_HEX >= 0x030d0000 + return boost::make_optional(Py_IsFinalizing() != 0); +// `_Py_IsFinalizing` is only available from CPython 3.7 +#elif PY_VERSION_HEX >= 0x03070000 return boost::make_optional(_Py_IsFinalizing() != 0); #else // There is no way of knowing on older versions. From 285576c3df128de600ef5e572b7c6c0997b395fe Mon Sep 17 00:00:00 2001 From: thervier Date: Tue, 29 Apr 2025 21:05:08 +0200 Subject: [PATCH 03/12] conanfile: workaround to copy dependency libs to link them manually (issue on MacOS, only ?, where the RPATH are not added to the dependencies) --- conanfile.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/conanfile.py b/conanfile.py index d2a74aa..2258f07 100644 --- a/conanfile.py +++ b/conanfile.py @@ -1,5 +1,7 @@ from conan import ConanFile, tools -from conan.tools.cmake import cmake_layout +from conan.tools.cmake import CMakeToolchain, cmake_layout +from conan.tools.files import copy +import os BOOST_COMPONENTS = [ "atomic", @@ -64,7 +66,7 @@ class QiPythonConan(ConanFile): "gtest/[~1.14]", ] - generators = "CMakeToolchain", "CMakeDeps" + generators = "CMakeDeps" # Binary configuration settings = "os", "compiler", "build_type", "arch" @@ -97,3 +99,15 @@ def layout(self): # The cmake_layout() sets the folders and cpp attributes to follow the # structure of a typical CMake project. cmake_layout(self) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["CMAKE_SKIP_RPATH"] = True + tc.generate() + + for dep in self.dependencies.values(): + if not dep.package_folder: + continue # skip if the dependency doesn't have a resolved package + copy(self, "*.dll", src=dep.package_folder, dst=self.build_folder) + copy(self, "*.dylib*", src=dep.package_folder, dst=self.build_folder) + copy(self, "*.so*", src=dep.package_folder, dst=self.build_folder) From 7d91e9f9014bef3f1759de5c14ced9233589a765 Mon Sep 17 00:00:00 2001 From: thervier Date: Tue, 29 Apr 2025 21:06:20 +0200 Subject: [PATCH 04/12] pyproject: bump version to 3.1.6 + cleaning --- pyproject.toml | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 6ccd0da..5b619ff 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ build-backend = "scikit_build_core.build" [project] name = "qi" description = "LibQi Python bindings" -version = "3.1.5" +version = "3.1.6" readme = "README.rst" requires-python = ">=3.7" license = { "file" = "COPYING" } @@ -37,16 +37,19 @@ classifiers=[ "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Programming Language :: Python :: 3 :: Only", ] maintainers = [ + { name = "Thibault Hervier", email = "thibault@fr2g.io" }, { email = "framework@aldebaran.com" }, { name = "Vincent Palancher", email = "vincent.palancher@aldebaran.com" }, { name = "Jérémy Monnon", email = "jmonnon@aldebaran.com" }, ] [project.urls] -repository = "https://github.com/aldebaran/libqi-python" +repository = "https://https://github.com/funwithagents/libqi-python" [tool.scikit-build] # Rely only on CMake install, not on Python packages detection. @@ -55,13 +58,3 @@ wheel.packages = [] [tool.scikit-build.cmake.define] # Disable building tests by default when building a wheel. BUILD_TESTING = "OFF" - -[tool.cibuildwheel] -build = "cp*manylinux*x86_64" -build-frontend = "build" - -[tool.cibuildwheel.linux] -before-all = ["ci/cibuildwheel_linux_before_all.sh {package}"] - -[tool.cibuildwheel.linux.config-settings] -"cmake.args" = ["--preset=conan-release"] From b4107e2f0320724844e5f6382e856fae73f4baa0 Mon Sep 17 00:00:00 2001 From: thervier Date: Tue, 29 Apr 2025 23:33:44 +0200 Subject: [PATCH 05/12] Add scripts to setup and build on Linux --- execute_build_wheel_linux.sh | 24 ++++++++++++++++++++++++ requirements_linux.txt | 7 +++++++ 2 files changed, 31 insertions(+) create mode 100755 execute_build_wheel_linux.sh create mode 100644 requirements_linux.txt diff --git a/execute_build_wheel_linux.sh b/execute_build_wheel_linux.sh new file mode 100755 index 0000000..e66ab8a --- /dev/null +++ b/execute_build_wheel_linux.sh @@ -0,0 +1,24 @@ +#!/bin/bash +conan profile detect + +# Set needed variables for libqi repository dependency +QI_REPOSITORY="https://github.com/funwithagents/libqi.git" +QI_VERSION="4.0.5" +QI_PATH="$PWD/../libqi" +rm -rf $QI_PATH +# Clone liqi respository +git clone --depth=1 --branch "qi-framework-v${QI_VERSION}" "${QI_REPOSITORY}" "${QI_PATH}" +# Link the libqi dependency by loading its conanfile into conan cache +conan export "${QI_PATH}" --version "${QI_VERSION}" + +# Build +conan install . --build=missing -c tools.build:skip_test=true -c '&:tools.build:skip_test=true' +cmake --list-presets # => it should list the preset "conan-linux-x86_64-gcc-release" +cmake --preset conan-linux-x86_64-gcc-release +cmake --build --preset conan-linux-x86_64-gcc-release -j8 + +# Generate wheel +python -m build --config-setting cmake.define.CMAKE_TOOLCHAIN_FILE=$PWD/build/linux-x86_64-gcc-release/generators/conan_toolchain.cmake + +# Repair wheel (using all the dependency libs that have been previously copied by conan) +LD_LIBRARY_PATH=$PWD/build/linux-x86_64-gcc-release/lib/ auditwheel repair --strip --plat manylinux_2_34_x86_64 dist/qi-3.1.6-cp313-cp313-linux_x86_64.whl -w ./dist/fixed/ diff --git a/requirements_linux.txt b/requirements_linux.txt new file mode 100644 index 0000000..52d3328 --- /dev/null +++ b/requirements_linux.txt @@ -0,0 +1,7 @@ +cmake +conan +qibuild +numpy +build +patchelf +auditwheel From 02ec93975b40de4d50aaa17f1c103fc773794a49 Mon Sep 17 00:00:00 2001 From: thervier Date: Wed, 30 Apr 2025 00:09:56 +0200 Subject: [PATCH 06/12] Add scripts to setup and build on MacOS --- execute_build_wheel_macos.sh | 23 +++++++++++++++++++++++ requirements_macos.txt | 7 +++++++ 2 files changed, 30 insertions(+) create mode 100755 execute_build_wheel_macos.sh create mode 100644 requirements_macos.txt diff --git a/execute_build_wheel_macos.sh b/execute_build_wheel_macos.sh new file mode 100755 index 0000000..36951a8 --- /dev/null +++ b/execute_build_wheel_macos.sh @@ -0,0 +1,23 @@ +#!/bin/bash +conan profile detect + +# Set needed variables for libqi repository dependency +QI_REPOSITORY="https://github.com/funwithagents/libqi.git" +QI_VERSION="4.0.5" +QI_PATH="$PWD/../libqi" +rm -rf $QI_PATH +# Clone liqi respository +git clone --depth=1 --branch "qi-framework-v${QI_VERSION}" "${QI_REPOSITORY}" "${QI_PATH}" +# Link the libqi dependency by loading its conanfile into conan cache +conan export "${QI_PATH}" --version "${QI_VERSION}" + +# Build +conan install . --build=missing -c tools.build:skip_test=true -c '&:tools.build:skip_test=true' +cmake --list-presets # => it should list the preset "conan-macos-armv8-apple-clang-release" +cmake --preset conan-macos-armv8-apple-clang-release +cmake --preset conan-macos-armv8-apple-clang-release +# Generate wheel +python -m build --config-setting cmake.define.CMAKE_TOOLCHAIN_FILE=$PWD/build/macos-armv8-apple-clang-release/generators/conan_toolchain.cmake + +# Repair wheel (using all the dependency libs that have been previously copied by conan) +DYLD_LIBRARY_PATH=$PWD/build/macos-armv8-apple-clang-release/lib delocate-wheel -w ./dist/fixed/ --check-archs ./dist/qi-3.1.6-cp313-cp313-macosx_15_0_arm64.whl diff --git a/requirements_macos.txt b/requirements_macos.txt new file mode 100644 index 0000000..6ac2dd2 --- /dev/null +++ b/requirements_macos.txt @@ -0,0 +1,7 @@ +cmake +conan +qibuild +numpy +build +patchelf +delocate From 102e827104eaebf45aa5cd495cf5a28eefdf9385 Mon Sep 17 00:00:00 2001 From: Thibault Hervier Date: Wed, 7 May 2025 14:00:42 +0200 Subject: [PATCH 07/12] Update README (and switch to md) --- README.md | 105 ++++++++++++++++++++++++++++ README.rst | 199 ----------------------------------------------------- 2 files changed, 105 insertions(+), 199 deletions(-) create mode 100644 README.md delete mode 100644 README.rst diff --git a/README.md b/README.md new file mode 100644 index 0000000..e9ea1c9 --- /dev/null +++ b/README.md @@ -0,0 +1,105 @@ +# qi package - Python binding for Libqi + +This repository contains the Python bindings of [LibQi](https://github.com/funwithagents/libqi), the library used to communicate with robots using Naoqi (Nao & Pepper). + +These LibQi python bindings correspond to the `qi` Python module. + +## Up-to-date repository for compatibility with recent Python versions and OS + +- This repository is a fork of the official libqi-python repository (that seems to be not maintained by Aldebaran anymore). +- I created it mainly to update the code of the package to be able to build it with recent versions of Python (3.10+) on MacOS and Linux + +## Pre-built packages + +- Check the [Releases](https://github.com/funwithagents/libqi-python/releases) to directly retrieve python wheels compatible with recent version of Python, for MacOS and Linux +- To install the packages + - download the wheel file (.whl) corresponding to your python version and OS + - install the package using `pip install path/to/wheel.whl` + +## Building from sources + +
+MacOS + +>[!NOTE] +>💡 This has been tested on a Mac with arm64 architecture & MacOS Sequoia (15.3.1) + +- setup you python installation (you can use pyenv if you want to be able to choose a specific Python version) + - `pyenv install 3.13` + - `pyenv global 3.13` +- setup a python environment and switch to it (for example using venv) + - `python -m venv ~/py-venv/py3.13-buildlibqipython` + - `source ~/py-venv/py3.13-buildlibqipython/bin/activate` +- install needed python packages + - `pip install -r requirements_macos.txt` +- clone this repository and go to the root of it +- generate (if not already done) your conan profile + - `conan profile detect` +- check you conan profile + - `cat ~/.conan2/profiles/default` + - it should display something similar to this + + ``` + [settings] + arch=armv8 + build_type=Release + compiler=apple-clang + compiler.cppstd=gnu17 + compiler.libcxx=libc++ + compiler.version=16 + os=Macos + ``` + +- execute the build script with all the needed steps + - `chmod +x build_wheel_macos.sh` + - `./build_wheel_macos.sh` + +🥳 **Congratulations** +It should have generated the python wheel : +- in folder `./dist/fixed/` +- with name similar to `qi-3.1.6-cp313-cp313-macosx_15_0_arm64.whl` +
+ +
+Linux + +>[!NOTE] +>💡 This has been tested on a x86_64 architecture & Ubuntu 22.04 + +- install c++ compiler + - `sudo apt-get install build-essential` +- setup you python installation (you can use pyenv if you want to be able to choose a specific Python version) + - `pyenv install 3.13` + - `pyenv global 3.13` +- setup a python environment and switch to it (for example using venv) + - `python -m venv ~/py-venv/py3.13-buildlibqipython` + - `source ~/py-venv/py3.13-buildlibqipython/bin/activate` +- install needed python packages + - `pip install -r requirements_linux.txt` +- clone this repository and go to the root of it +- generate (if not already done) your conan profile + - `conan profile detect` +- check you conan profile + - `cat $HOME/.conan2/profiles/default` + - it should display something similar to this + + ``` + [settings] + arch=x86_64 + build_type=Release + compiler=gcc + compiler.cppstd=gnu17 + compiler.libcxx=libstdc++11 + compiler.version=11 + os=Linux + ``` + +- execute the build script with all the needed steps + - `chmod +x build_wheel_linux.sh` + - `./build_wheel_linux.sh` + +🥳 **Congratulations** +It should have generated the python wheel : +- in folder `./dist/fixed/` +- with name similar to `qi-3.1.6-cp313-cp313-manylinux_2_34_x86_64.whl` +
diff --git a/README.rst b/README.rst deleted file mode 100644 index 8d35691..0000000 --- a/README.rst +++ /dev/null @@ -1,199 +0,0 @@ -=================================== -LibQiPython - LibQi Python bindings -=================================== - -This repository contains the official Python bindings of the `LibQi`__, the ``qi`` -Python module. - -__ LibQi_repo_ - -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: - - .. code-block:: console - - apt-get install python3-venv - python3 -m venv ~/my-venv # Use the path of your convenience. - source ~/my-venv/bin/activate - -.. note:: - The CMake project offers several configuration options and exports a set - of targets when installed. You may refer to the ``CMakeLists.txt`` file - for more details about available parameters and exported targets. - -.. note:: - The 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. - -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: - -.. code-block:: console - - # 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. - -.. code-block:: console - - # 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. - -.. code-block:: console - - 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: - -.. code-block:: console - - 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: - -.. code-block:: console - - 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: - -.. code-block:: console - - 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. - -.. code-block:: console - - # `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: - -.. code-block:: console - - 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. - -.. code-block:: console - - 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. - -.. note:: - `auditwheel` requires the `patchelf` utility program on Linux. You may need - to install it (on Ubuntu: `apt-get install patchelf`). - -.. code-block:: console - - 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. - -__ CMake_toolchains_ - -.. _LibQi_repo: https://github.com/aldebaran/libqi -.. _scikit-build: https://scikit-build.readthedocs.io/en/latest/ -.. _CMake_toolchains: https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html -.. _CTest: https://cmake.org/cmake/help/latest/manual/ctest.1.html From 6c3965996f4d26271c8f56c975d6318071b457dc Mon Sep 17 00:00:00 2001 From: thervier Date: Wed, 7 May 2025 17:20:54 +0200 Subject: [PATCH 08/12] Fixes in README.md --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index e9ea1c9..b1c092f 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ These LibQi python bindings correspond to the `qi` Python module. ## Up-to-date repository for compatibility with recent Python versions and OS -- This repository is a fork of the official libqi-python repository (that seems to be not maintained by Aldebaran anymore). +- This repository is a fork of the official [libqi-python](https://github.com/aldebaran/libqi-python) repository (that seems to be not maintained by Aldebaran anymore). - I created it mainly to update the code of the package to be able to build it with recent versions of Python (3.10+) on MacOS and Linux ## Pre-built packages @@ -51,8 +51,8 @@ These LibQi python bindings correspond to the `qi` Python module. ``` - execute the build script with all the needed steps - - `chmod +x build_wheel_macos.sh` - - `./build_wheel_macos.sh` + - `chmod +x execute_build_wheel_macos.sh` + - `./execute_build_wheel_macos.sh` 🥳 **Congratulations** It should have generated the python wheel : @@ -95,8 +95,8 @@ It should have generated the python wheel : ``` - execute the build script with all the needed steps - - `chmod +x build_wheel_linux.sh` - - `./build_wheel_linux.sh` + - `chmod +x execute_build_wheel_linux.sh` + - `./execute_build_wheel_linux.sh` 🥳 **Congratulations** It should have generated the python wheel : From 9a3d117de5849b06119b229ebcc31bc2871f4716 Mon Sep 17 00:00:00 2001 From: thervier Date: Wed, 7 May 2025 17:21:13 +0200 Subject: [PATCH 09/12] Fix in pyproject.toml after README change --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 5b619ff..d49f24e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ build-backend = "scikit_build_core.build" name = "qi" description = "LibQi Python bindings" version = "3.1.6" -readme = "README.rst" +readme = "README.md" requires-python = ">=3.7" license = { "file" = "COPYING" } keywords=[ From 41afd000bf042740865eae99432b9f172ffed4cd Mon Sep 17 00:00:00 2001 From: thervier Date: Wed, 7 May 2025 17:47:12 +0200 Subject: [PATCH 10/12] README: small fix --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b1c092f..5a12d89 100644 --- a/README.md +++ b/README.md @@ -21,8 +21,7 @@ These LibQi python bindings correspond to the `qi` Python module.
MacOS ->[!NOTE] ->💡 This has been tested on a Mac with arm64 architecture & MacOS Sequoia (15.3.1) +💡 This has been tested on a Mac with arm64 architecture & MacOS Sequoia (15.3.1) - setup you python installation (you can use pyenv if you want to be able to choose a specific Python version) - `pyenv install 3.13` @@ -63,8 +62,7 @@ It should have generated the python wheel :
Linux ->[!NOTE] ->💡 This has been tested on a x86_64 architecture & Ubuntu 22.04 +💡 This has been tested on a x86_64 architecture & Ubuntu 22.04 - install c++ compiler - `sudo apt-get install build-essential` From c617f774ed8b07fcaee4c235ae6d6dd50f808a41 Mon Sep 17 00:00:00 2001 From: thervier Date: Wed, 7 May 2025 17:47:44 +0200 Subject: [PATCH 11/12] MacOS build script: make it generic for Python and MacOS version --- execute_build_wheel_macos.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/execute_build_wheel_macos.sh b/execute_build_wheel_macos.sh index 36951a8..394f442 100755 --- a/execute_build_wheel_macos.sh +++ b/execute_build_wheel_macos.sh @@ -1,5 +1,4 @@ #!/bin/bash -conan profile detect # Set needed variables for libqi repository dependency QI_REPOSITORY="https://github.com/funwithagents/libqi.git" @@ -19,5 +18,11 @@ cmake --preset conan-macos-armv8-apple-clang-release # Generate wheel python -m build --config-setting cmake.define.CMAKE_TOOLCHAIN_FILE=$PWD/build/macos-armv8-apple-clang-release/generators/conan_toolchain.cmake +# Retrieve python version as "3Y" for 3.Y.Z ("313" for python 3.13.Z) +python_version=$(python --version 2>&1 | awk '{print $2}' | cut -d'.' -f1,2 | sed 's/\.//g') +# Retrieve macOS major version +macos_version=$(sw_vers -productVersion) +macos_major_version=$(echo $macos_version | cut -d'.' -f1) + # Repair wheel (using all the dependency libs that have been previously copied by conan) -DYLD_LIBRARY_PATH=$PWD/build/macos-armv8-apple-clang-release/lib delocate-wheel -w ./dist/fixed/ --check-archs ./dist/qi-3.1.6-cp313-cp313-macosx_15_0_arm64.whl +DYLD_LIBRARY_PATH=$PWD/build/macos-armv8-apple-clang-release/lib delocate-wheel -w ./dist/fixed/ --check-archs ./dist/qi-3.1.6-cp${python_version}-cp${python_version}-macosx_${macos_major_version}_0_arm64.whl From 19388cc2a150fc4d4b0e32e21b75cbe4792f7e76 Mon Sep 17 00:00:00 2001 From: thervier Date: Wed, 7 May 2025 20:06:42 +0200 Subject: [PATCH 12/12] Linux build script: make it generic for Python and Linux compatibility --- README.md | 2 +- execute_build_wheel_linux.sh | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5a12d89..3250f1e 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,7 @@ It should have generated the python wheel : - generate (if not already done) your conan profile - `conan profile detect` - check you conan profile - - `cat $HOME/.conan2/profiles/default` + - `cat ~/.conan2/profiles/default` - it should display something similar to this ``` diff --git a/execute_build_wheel_linux.sh b/execute_build_wheel_linux.sh index e66ab8a..907fb52 100755 --- a/execute_build_wheel_linux.sh +++ b/execute_build_wheel_linux.sh @@ -1,5 +1,4 @@ #!/bin/bash -conan profile detect # Set needed variables for libqi repository dependency QI_REPOSITORY="https://github.com/funwithagents/libqi.git" @@ -20,5 +19,10 @@ cmake --build --preset conan-linux-x86_64-gcc-release -j8 # Generate wheel python -m build --config-setting cmake.define.CMAKE_TOOLCHAIN_FILE=$PWD/build/linux-x86_64-gcc-release/generators/conan_toolchain.cmake +# Retrieve python version as "3Y" for 3.Y.Z ("313" for python 3.13.Z) +python_version=$(python --version 2>&1 | awk '{print $2}' | cut -d'.' -f1,2 | sed 's/\.//g') +# Retrieve the platform compatibility for the wheel, using auditwheel show +constraint_tag=$(auditwheel show ./dist/qi-3.1.6-cp${python_version}-cp${python_version}-linux_x86_64.whl | grep 'This constrains the platform tag to' | sed -E 's/.*"([^"]+)".*/\1/') + # Repair wheel (using all the dependency libs that have been previously copied by conan) -LD_LIBRARY_PATH=$PWD/build/linux-x86_64-gcc-release/lib/ auditwheel repair --strip --plat manylinux_2_34_x86_64 dist/qi-3.1.6-cp313-cp313-linux_x86_64.whl -w ./dist/fixed/ +LD_LIBRARY_PATH=$PWD/build/linux-x86_64-gcc-release/lib/ auditwheel repair --strip --plat ${constraint_tag} dist/qi-3.1.6-cp${python_version}-cp${python_version}-linux_x86_64.whl -w ./dist/fixed/