Skip to content

Commit

Permalink
Merge branch 'devel' into fix-cereal-link
Browse files Browse the repository at this point in the history
  • Loading branch information
jcarpent authored Sep 2, 2024
2 parents d8b56b9 + 5bc2b9d commit 515ce6c
Show file tree
Hide file tree
Showing 34 changed files with 847 additions and 952 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ci-arch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name: CI - ArchLinux
on:
push:
pull_request:
paths-ignore:
- CHANGELOG.md

jobs:
build-with-arch:
Expand All @@ -14,7 +16,7 @@ jobs:

- uses: actions/checkout@v4
with:
submodules: true
submodules: recursive

- run: cmake -B build -S . -DBUILD_PYTHON_INTERFACE=ON
- run: cmake --build build
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/ci-linux-osx-win-conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name: CI - Linux/OSX/Windows - Conda
on:
push:
pull_request:
paths-ignore:
- CHANGELOG.md

jobs:
build-with-conda:
Expand All @@ -29,10 +31,6 @@ jobs:
compiler: clang-cl
- name: windows-latest
os: windows-latest
- name: macos-latest
os: macos-latest
build_type: Release
cxx_std: 14
- name: macos-latest
os: macos-latest
build_type: Debug
Expand All @@ -55,7 +53,9 @@ jobs:
continue_on_error: false

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: recursive

- uses: conda-incubator/setup-miniconda@v2
if: matrix.os != 'macos-14'
Expand All @@ -80,7 +80,7 @@ jobs:
# Workaround for https://github.com/conda-incubator/setup-miniconda/issues/186
conda config --remove channels defaults
# Compilation related dependencies
mamba install cmake compilers make pkg-config doxygen ninja graphviz
mamba install cmake compilers make pkg-config doxygen ninja graphviz typing_extensions
# Main dependencies
mamba install eigen simde
# Test dependencies
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/ci-linux-ros.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: CI - Linux - ROS
on: [push, pull_request]
on:
push:
pull_request:
paths-ignore:
- CHANGELOG.md

jobs:
CI:
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: recursive

- uses: conda-incubator/setup-miniconda@v2
with:
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/release-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: Release on PyPI [Linux]

on:
pull_request:
paths-ignore:
- CHANGELOG.md
release:
types:
- published
Expand Down Expand Up @@ -33,9 +35,9 @@ jobs:
build: "cp312-manylinux*"

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: 'true'
submodules: recursive
- uses: actions/setup-python@v4
with:
python-version: "3.10"
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/release-osx-win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: Release on PyPI [Windows, Mac]

on:
pull_request:
paths-ignore:
- CHANGELOG.md
release:
types:
- published
Expand All @@ -21,7 +23,7 @@ jobs:
toolset: v143

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: recursive

Expand Down Expand Up @@ -57,7 +59,7 @@ jobs:
run: |
# Workaround for https://github.com/conda-incubator/setup-miniconda/issues/186
conda config --remove channels defaults
mamba install doxygen graphviz eigen simde cmake compilers
mamba install doxygen graphviz eigen simde cmake compilers typing_extensions
- name: Print environment [Conda]
if: contains(matrix.os, 'macos') || contains(matrix.os, 'windows')
Expand Down
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[submodule "external/pybind11"]
path = bindings/python/external/pybind11
url = https://github.com/pybind/pybind11
[submodule "bindings/python/external/nanobind"]
path = bindings/python/external/nanobind
url = https://github.com/wjakob/nanobind
[submodule "cmake-module"]
path = cmake-module
url = https://github.com/jrl-umi3218/jrl-cmakemodules.git
Expand Down
13 changes: 10 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,22 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Fixed
* CMake: Fix link to system cereal in tests ([#353](https://github.com/Simple-Robotics/proxsuite/pull/352))

### Added
* Stub files for Python bindings, using [nanobind's native support](https://nanobind.readthedocs.io/en/latest/typing.html#stub-generation) ([#340](https://github.com/Simple-Robotics/proxsuite/pull/340))

### Changed
* Change Python bindings to use nanobind instead of pybind11 ([#340](https://github.com/Simple-Robotics/proxsuite/pull/340))


## [0.6.7] - 2024-08-27

### Added
* Fix mu update function for PrimalLDLT backend ([#349](https://github.com/Simple-Robotics/proxsuite/pull/349))
* Allow use of installed pybind11, cereal and jrl-cmakemodules via cmake
* Add compatibility with jrl-cmakemodules workspace ([#339](https://github.com/Simple-Robotics/proxsuite/pull/339))
* Specifically mention that timings are in microseconds ([#340](https://github.com/Simple-Robotics/proxsuite/pull/340))
* Fix cereal include directory in cmake ([#340](https://github.com/Simple-Robotics/proxsuite/pull/340))
* Extend doc with hint for conda installation from source ([#340](https://github.com/Simple-Robotics/proxsuite/pull/340))
* Specifically mention that timings are in microseconds ([#342](https://github.com/Simple-Robotics/proxsuite/pull/342))
* Fix cereal include directory in cmake ([#342](https://github.com/Simple-Robotics/proxsuite/pull/342))
* Extend doc with hint for conda installation from source ([#342](https://github.com/Simple-Robotics/proxsuite/pull/342))

### Fixed
* Fix inequality constraints return in QPLayer ([#343](https://github.com/Simple-Robotics/proxsuite/pull/343))
Expand Down
73 changes: 57 additions & 16 deletions bindings/python/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
if(UNIX)
set(PYTHON_COMPONENTS Development.Module)
set(PYTHON_COMPONENTS Interpreter Development.Module)
endif()

include(${JRL_CMAKE_MODULES}/python.cmake)
include(${JRL_CMAKE_MODULES}/python-helpers.cmake)

findpython(REQUIRED Development.Module)
option(GENERATE_PYTHON_STUBS "Generate Python stubs" OFF)

findpython(REQUIRED)
set(Python_INCLUDE_DIRS ${Python3_INCLUDE_DIRS})
# Nanobind expects these targets instead of Python3::*
# https://github.com/jrl-umi3218/jrl-cmakemodules/issues/708
add_library(Python::Module ALIAS Python3::Module)
add_executable(Python::Interpreter ALIAS Python3::Interpreter)

if(IS_ABSOLUTE ${PYTHON_SITELIB})
set(${PYWRAP}_INSTALL_DIR ${PYTHON_SITELIB}/${PROJECT_NAME})
Expand All @@ -14,11 +21,21 @@ else()
${CMAKE_INSTALL_PREFIX}/${PYTHON_SITELIB}/${PROJECT_NAME})
endif()

find_package(pybind11 CONFIG)
if(NOT pybind11_FOUND)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/external/pybind11)
add_subdirectory(external/pybind11
${CMAKE_CURRENT_BINARY_DIR}/external/pybind11)
cmake_policy(PUSH)
cmake_policy(SET CMP0074 NEW)
# Detect the installed nanobind package and import it into CMake
execute_process(
COMMAND "${Python_EXECUTABLE}" -m nanobind --cmake_dir
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE nanobind_ROOT)
find_package(nanobind CONFIG)
cmake_policy(POP)
if(NOT nanobind_FOUND)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/external/nanobind)
add_subdirectory(external/nanobind
${CMAKE_CURRENT_BINARY_DIR}/external/nanobind)
else()
message(STATUS "Found installed nanobind.")
endif()

add_custom_target(${PROJECT_NAME}_python)
Expand All @@ -29,14 +46,12 @@ file(GLOB_RECURSE PYWRAP_SOURCES ${CMAKE_CURRENT_LIST_DIR}/src/*.cpp)

# Add simd feature detectors for current intel CPU
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "(x86)|(X86)|(amd64)|(AMD64)")
python3_add_library(instructionset MODULE helpers/instruction-set.cpp)
nanobind_add_module(instructionset helpers/instruction-set.cpp)
add_dependencies(${PROJECT_NAME}_python instructionset)
target_link_libraries(instructionset PRIVATE proxsuite pybind11::module)
target_link_libraries(instructionset PRIVATE proxsuite)
set_target_properties(
instructionset
PROPERTIES OUTPUT_NAME instructionset
PREFIX ""
SUFFIX ${PYTHON_EXT_SUFFIX}
LIBRARY_OUTPUT_DIRECTORY
"${PROJECT_BINARY_DIR}/bindings/python/${PROJECT_NAME}"
LIBRARY_OUTPUT_DIRECTORY_RELEASE
Expand All @@ -58,6 +73,20 @@ if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "(x86)|(X86)|(amd64)|(AMD64)")
TARGETS instructionset
EXPORT ${TARGETS_EXPORT_NAME}
DESTINATION ${${PYWRAP}_INSTALL_DIR})
if(GENERATE_PYTHON_STUBS)
nanobind_add_stub(
instructionset_stub
MODULE
instructionset
OUTPUT
instructionset.pyi
PYTHON_PATH
$<TARGET_FILE_DIR:instructionset>
DEPENDS
instructionset)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/instructionset.pyi
DESTINATION ${${PYWRAP}_INSTALL_DIR})
endif()
endif()

function(list_filter list regular_expression dest_list)
Expand All @@ -72,12 +101,12 @@ function(list_filter list regular_expression dest_list)
endfunction(list_filter)

function(CREATE_PYTHON_TARGET target_name COMPILE_OPTIONS dependencies)
python3_add_library(${target_name} MODULE ${PYWRAP_SOURCES} ${PYWRAP_HEADERS})
nanobind_add_module(${target_name} ${PYWRAP_SOURCES} ${PYWRAP_HEADERS})
add_dependencies(${PROJECT_NAME}_python ${target_name})

target_link_libraries(${target_name} PUBLIC ${dependencies} pybind11::module)
target_link_libraries(${target_name} PUBLIC ${dependencies})
target_compile_options(${target_name} PRIVATE ${COMPILE_OPTIONS})
target_link_libraries(${target_name} PRIVATE proxsuite pybind11::module)
target_link_libraries(${target_name} PRIVATE proxsuite)
target_compile_definitions(${target_name}
PRIVATE PYTHON_MODULE_NAME=${target_name})

Expand All @@ -104,8 +133,6 @@ function(CREATE_PYTHON_TARGET target_name COMPILE_OPTIONS dependencies)
set_target_properties(
${target_name}
PROPERTIES OUTPUT_NAME ${target_name}
PREFIX ""
SUFFIX ${PYTHON_EXT_SUFFIX}
LIBRARY_OUTPUT_DIRECTORY
"${PROJECT_BINARY_DIR}/bindings/python/${PROJECT_NAME}"
LIBRARY_OUTPUT_DIRECTORY_RELEASE
Expand All @@ -126,6 +153,20 @@ function(CREATE_PYTHON_TARGET target_name COMPILE_OPTIONS dependencies)
endif()

install(TARGETS ${target_name} DESTINATION ${${PYWRAP}_INSTALL_DIR})
if(GENERATE_PYTHON_STUBS)
nanobind_add_stub(
${target_name}_stub
MODULE
${target_name}
OUTPUT
${target_name}.pyi
PYTHON_PATH
$<TARGET_FILE_DIR:${target_name}>
DEPENDS
${target_name})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${target_name}.pyi
DESTINATION ${${PYWRAP}_INSTALL_DIR})
endif()
endfunction()

if(CMAKE_CXX_COMPILER_ID MATCHES MSVC)
Expand Down
1 change: 1 addition & 0 deletions bindings/python/external/nanobind
Submodule nanobind added at 9641bb
1 change: 0 additions & 1 deletion bindings/python/external/pybind11
Submodule pybind11 deleted from 849322
7 changes: 4 additions & 3 deletions bindings/python/helpers/instruction-set.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
//
// Copyright (c) 2022 INRIA
// Copyright (c) 2022-2024 INRIA
//

#include <pybind11/pybind11.h>
#include <nanobind/nanobind.h>
#include <nanobind/stl/string.h>

#include <proxsuite/helpers/instruction-set.hpp>

namespace proxsuite {
namespace helpers {
namespace python {

PYBIND11_MODULE(instructionset, m)
NB_MODULE(instructionset, m)
{
m.doc() = R"pbdoc(
CPU info library
Expand Down
Loading

0 comments on commit 515ce6c

Please sign in to comment.