Skip to content

Commit

Permalink
Nacho/scikit build core (#198)
Browse files Browse the repository at this point in the history
* Migrate to scikit-build-core

First iteration

* Make targets

* Editable works again!

* Avoid installing eigen/tbb into python package

* Fix Werror builds

* Add pybind11 to build system requirements

* Move requirements up

* Add min cmake

* This is not required anymore

* Add CCache support. Now it make a lot of sense

* Get all dependencies

* Fix pyproject.toml

* Add also ninja and cmake for editable mode

* Now install is the default target

* Not required anymore

* fix readme

---------

Co-authored-by: tizianoGuadagnino <frevo93@gmail.com>
  • Loading branch information
nachovizzo and tizianoGuadagnino authored Aug 3, 2023
1 parent acfd813 commit 1b954d5
Show file tree
Hide file tree
Showing 13 changed files with 105 additions and 206 deletions.
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
.PHONY: cpp

editable:
SETUPTOOLS_ENABLE_FEATURES="legacy-editable" pip install --verbose --prefix=$(shell python3 -m site --user-base) --editable ./python/

install:
@pip install --verbose ./python/

uninstall:
@pip -v uninstall kiss_icp

editable:
@pip install scikit-build-core pyproject_metadata pathspec pybind11 ninja cmake
@pip install --no-build-isolation -ve ./python/

cpp:
@cmake -Bbuild cpp/kiss_icp/
@cmake --build build -j$(nproc --all)
7 changes: 5 additions & 2 deletions cpp/kiss_icp/3rdparty/eigen/eigen.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@ set(EIGEN_BUILD_BLAS OFF CACHE BOOL "Don't build blas module")
set(EIGEN_BUILD_LAPACK OFF CACHE BOOL "Don't build lapack module")

include(FetchContent)
FetchContent_Declare(eigen SYSTEM URL https://github.com/nachovizzo/eigen/archive/refs/tags/3.4.90.tar.gz)
FetchContent_MakeAvailable(eigen)
FetchContent_Declare(eigen URL https://github.com/nachovizzo/eigen/archive/refs/tags/3.4.90.tar.gz)
if(NOT eigen_POPULATED)
FetchContent_Populate(eigen)
add_subdirectory(${eigen_SOURCE_DIR} ${eigen_BINARY_DIR} SYSTEM EXCLUDE_FROM_ALL)
endif()

if(${CMAKE_VERSION} VERSION_LESS 3.25)
get_target_property(eigen_include_dirs eigen INTERFACE_INCLUDE_DIRECTORIES)
Expand Down
7 changes: 5 additions & 2 deletions cpp/kiss_icp/3rdparty/tbb/tbb.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@ option(TBB_STRICT OFF)
option(TBB_TEST OFF)

include(FetchContent)
FetchContent_Declare(tbb SYSTEM URL https://github.com/oneapi-src/oneTBB/archive/refs/tags/v2021.8.0.tar.gz)
FetchContent_MakeAvailable(tbb)
FetchContent_Declare(tbb URL https://github.com/oneapi-src/oneTBB/archive/refs/tags/v2021.8.0.tar.gz)
if(NOT tbb_POPULATED)
FetchContent_Populate(tbb)
add_subdirectory(${tbb_SOURCE_DIR} ${tbb_BINARY_DIR} SYSTEM EXCLUDE_FROM_ALL)
endif()

if(${CMAKE_VERSION} VERSION_LESS 3.25)
get_target_property(tbb_include_dirs tbb INTERFACE_INCLUDE_DIRECTORIES)
Expand Down
11 changes: 11 additions & 0 deletions cpp/kiss_icp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,22 @@ cmake_minimum_required(VERSION 3.16...3.26)
project(kiss_icp_cpp VERSION 0.2.10 LANGUAGES CXX)

# Setup build options
option(USE_CCACHE "Build using Ccache if found on the path" ON)
option(USE_SYSTEM_EIGEN3 "Use system pre-installed Eigen" ON)
option(USE_SYSTEM_SOPHUS "Use system pre-installed Sophus" ON)
option(USE_SYSTEM_TSLMAP "Use system pre-installed tsl_robin" ON)
option(USE_SYSTEM_TBB "Use system pre-installed oneAPI/tbb" ON)

# ccache setup
if(USE_CCACHE)
find_program(CCACHE_PATH ccache)
if(CCACHE_PATH)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
message(STATUS "Using ccache: ${CCACHE_PATH}")
endif()
endif()

# Set build type (repeat here for C++ only consumers)
set(CMAKE_BUILD_TYPE Release)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
Expand Down
4 changes: 4 additions & 0 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ set(CMAKE_BUILD_TYPE Release)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

set(PYBIND11_NEWPYTHON ON)
find_package(Python COMPONENTS Interpreter Development.Module REQUIRED)
find_package(pybind11 CONFIG REQUIRED)

if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../cpp/kiss_icp/)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../cpp/kiss_icp ${CMAKE_CURRENT_BINARY_DIR}/kiss_icp)
else()
Expand Down
8 changes: 3 additions & 5 deletions python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ This should print the following help message:

### Install Python API (developer mode)

If you plan to modify the code then you need to setup the dev dependencies, luckilly, the only real
If you plan to modify the code then you need to setup the dev dependencies, luckily, the only real
requirements are a modern C++ compiler and the `pip` package manager, nothing else!, in Ubuntu-based
sytems this can be done with:
systems this can be done with:

```sh
sudo apt install g++ python3-pip
Expand All @@ -71,7 +71,7 @@ After that you can clone the code and install the python api:
```sh
git clone https://github.com/PRBonn/kiss-icp.git
cd kiss-icp
pip install --verbose .
make editable
```

### Install Python API (expert mode)
Expand Down Expand Up @@ -108,5 +108,3 @@ We envision KISS-ICP as a comunity-driven project, we love to see how the projec
<a href="https://github.com/PRBonn/kiss-icp/graphs/contributors">
<img src="https://contrib.rocks/image?repo=PRBonn/kiss-icp" />
</a>

[![Star History Chart](https://api.star-history.com/svg?repos=PRBonn/kiss-icp&type=Date)](https://star-history.com/#PRBonn/kiss-icp&Date)
30 changes: 1 addition & 29 deletions python/kiss_icp/pybind/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,6 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# Simply ignore the warnings when using scikit-build as the build system
if(${SKBUILD})
set(ignore ${PYTHON_NumPy_INCLUDE_DIRS})
set(ignore ${Python3_EXECUTABLE})
set(ignore ${Python3_INCLUDE_DIR})
set(ignore ${Python3_LIBRARY})
set(ignore ${Python3_NumPy_INCLUDE_DIRS})
set(ignore ${Python_EXECUTABLE})
set(ignore ${Python_INCLUDE_DIR})
set(ignore ${Python_LIBRARY})
set(ignore ${Python_NumPy_INCLUDE_DIRS})
set(ignore ${Python3_FIND_REGISTRY})
set(ignore ${Python3_ROOT_DIR})
set(ignore ${Python_FIND_REGISTRY})
set(ignore ${Python_ROOT_DIR})
endif()

option(USE_SYSTEM_PYBIND11 "Use system pre-installed pybind11" ON)
if(USE_SYSTEM_PYBIND11)
find_package(pybind11 QUIET)
endif()
if(NOT USE_SYSTEM_PYBIND11 OR NOT pybind11_FOUND)
set(USE_SYSTEM_PYBIND11 OFF)
include(${CMAKE_CURRENT_LIST_DIR}/pybind11/pybind11.cmake)
endif()

pybind11_add_module(kiss_icp_pybind MODULE kiss_icp_pybind.cpp)
target_link_libraries(kiss_icp_pybind PRIVATE kiss_icp::core kiss_icp::metrics)
install(TARGETS kiss_icp_pybind DESTINATION . COMPONENT python_bindings)
add_custom_target(install_python_bindings ${CMAKE_COMMAND} -DCMAKE_INSTALL_COMPONENT=python_bindings -P
"${PROJECT_BINARY_DIR}/cmake_install.cmake" DEPENDS kiss_icp_pybind)
install(TARGETS kiss_icp_pybind DESTINATION .)
22 changes: 0 additions & 22 deletions python/kiss_icp/pybind/__init__.py

This file was deleted.

29 changes: 0 additions & 29 deletions python/kiss_icp/pybind/pybind11/LICENSE

This file was deleted.

27 changes: 0 additions & 27 deletions python/kiss_icp/pybind/pybind11/pybind11.cmake

This file was deleted.

78 changes: 72 additions & 6 deletions python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,77 @@
[build-system]
requires = [
"cmake",
"ninja",
"scikit-build>=0.17.4",
"setuptools<66.0.0", # https://github.com/pypa/setuptools/issues/3772
requires = ["scikit_build_core", "pybind11"]
build-backend = "scikit_build_core.build"

[project]
name = "kiss-icp"
version = "0.2.10"
description = "Simple yet effective 3D LiDAR-Odometry registration pipeline"
readme = "README.md"
authors = [
{ name = "Ignacio Vizzo", email = "ignaciovizzo@gmail.com" },
]
requires-python = ">=3.7"
keywords = [
"LiDAR",
"Localization",
"Odometry",
"SLAM",
]
classifiers = [
"Intended Audience :: Developers",
"Intended Audience :: Education",
"Intended Audience :: Other Audience",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Operating System :: MacOS",
"Operating System :: Microsoft :: Windows",
"Operating System :: Unix",
"Programming Language :: C++",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
]
dependencies = [
"natsort",
"numpy",
"plyfile",
"pydantic <2",
"pyquaternion",
"rich",
"tqdm",
"typer[all]>=0.6.0",
]

[project.optional-dependencies]
all = [
"open3d>=0.13",
"ouster-sdk>=0.7.1",
"pyntcloud",
"PyYAML",
"trimesh",
]
visualizer = [
"open3d>=0.13",
]
build-backend = "setuptools.build_meta"

[project.scripts]
kiss_icp_pipeline = "kiss_icp.tools.cmd:run"

[project.urls]
Homepage = "https://github.com/PRBonn/kiss-icp"

[tool.scikit-build]
build-dir = "build/{wheel_tag}"
cmake.verbose = false
cmake.minimum-version = "3.16"
editable.mode = "redirect"
editable.rebuild = true
editable.verbose = true
sdist.exclude = ["pybind/"]
wheel.install-dir = "kiss_icp/pybind/"

[tool.black]
line-length = 100
Expand Down
28 changes: 0 additions & 28 deletions python/setup.cfg

This file was deleted.

53 changes: 0 additions & 53 deletions python/setup.py

This file was deleted.

0 comments on commit 1b954d5

Please sign in to comment.