Skip to content

Commit e4a1543

Browse files
authored
Make into pypi package with macos and windows support (#51)
* test for macos and windows support * Apple Clang has issues with std::log as constexpr * static cast implicit type conversions, include numeric * disable msvc warnings as error, add python cibuildwheel for macos * drop support for ubuntu 20.04, support python version >=3.8 * cache cmake build type for opencv windows * statically linked CRT OFF * add pypi workflow * all set for pip install * fix artifact same-name error due to shift to upload-artifact@v4 * try this * remove matrix.version, matrix.os for artifact name is enough * modify readme for pip install * bump version * cache v2 will literally break CI from 1st Feb 2025
1 parent 95bc9fe commit e4a1543

File tree

17 files changed

+162
-41
lines changed

17 files changed

+162
-41
lines changed

.github/workflows/cpp.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
runs-on: ${{ matrix.os }}
1515
strategy:
1616
matrix:
17-
os: [ubuntu-20.04, ubuntu-22.04, ubuntu-24.04]
17+
os: [ubuntu-24.04, ubuntu-22.04, windows-2022, macos-14, macos-15]
1818
steps:
1919
- uses: actions/checkout@v3
2020
- name: Setup cmake
@@ -35,12 +35,12 @@ jobs:
3535
runs-on: ${{ matrix.os }}
3636
strategy:
3737
matrix:
38-
os: [ubuntu-20.04, ubuntu-22.04, ubuntu-24.04]
38+
os: [ubuntu-22.04, ubuntu-24.04]
3939

4040
steps:
4141
- uses: actions/checkout@v3
4242
- name: Cache dependencies
43-
uses: actions/cache@v2
43+
uses: actions/cache@v4
4444
with:
4545
path: ~/.apt/cache
4646
key: ${{ runner.os }}-apt-${{ hashFiles('**/ubuntu_dependencies.yml') }}

.github/workflows/pypi.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Publish to PyPI.org
2+
on:
3+
release:
4+
types: [published]
5+
push:
6+
branches: ["main"]
7+
pull_request:
8+
branches: ["main"]
9+
10+
jobs:
11+
build_sdist:
12+
name: Build source distribution
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v3
16+
17+
- name: Build sdist
18+
run: pipx run build --sdist ${{github.workspace}}/python/
19+
- name: Move sdist to dist
20+
run: mkdir -p dist && mv ${{github.workspace}}/python/dist/*.tar.gz dist/
21+
22+
- uses: actions/upload-artifact@v4
23+
with:
24+
path: dist/*.tar.gz
25+
26+
cibuildwheel:
27+
name: Build wheels on ${{ matrix.os }}
28+
runs-on: ${{ matrix.os }}
29+
strategy:
30+
matrix:
31+
os: [ubuntu-24.04, windows-2022, macos-15]
32+
33+
steps:
34+
- uses: actions/checkout@v3
35+
36+
- name: Build test wheels (only PRs)
37+
if: github.event_name != 'release'
38+
uses: pypa/[email protected]
39+
env: # build 1 build per platform just to make sure we can do it later when releasing
40+
CIBW_BUILD: "cp310-*"
41+
with:
42+
package-dir: ${{github.workspace}}/python/
43+
44+
- name: Build all wheels
45+
if: github.event_name == 'release'
46+
uses: pypa/[email protected]
47+
with:
48+
package-dir: ${{github.workspace}}/python/
49+
50+
- uses: actions/upload-artifact@v4
51+
with:
52+
name: artifact-${{ matrix.os }}
53+
path: ./wheelhouse/*.whl
54+
55+
pypi:
56+
if: github.event_name == 'release'
57+
needs: [cibuildwheel, build_sdist]
58+
runs-on: ubuntu-latest
59+
steps:
60+
- uses: actions/download-artifact@v4
61+
with:
62+
name: artifact
63+
path: dist
64+
65+
- uses: pypa/gh-action-pypi-publish@release/v1
66+
with:
67+
password: ${{ secrets.PYPI_API_TOKEN }}

.github/workflows/python.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ${{ matrix.os }}
1111
strategy:
1212
matrix:
13-
os: [ubuntu-24.04, ubuntu-22.04, ubuntu-20.04]
13+
os: [ubuntu-24.04, ubuntu-22.04, windows-2022, macos-14, macos-15]
1414

1515
steps:
1616
- uses: actions/checkout@v3

README.md

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
<a href="https://github.com/PRBonn/MapClosures/releases"><img src="https://img.shields.io/github/v/release/PRBonn/MapClosures?label=version" /></a>
44
<a href="https://github.com/PRBonn/MapClosures/blob/main/LICENSE"><img src=https://img.shields.io/badge/license-MIT-green" /></a>
55
<a href="https://github.com/PRBonn/MapClosures/blob/main/"><img src="https://img.shields.io/badge/Linux-FCC624?logo=linux&logoColor=black" /></a>
6+
<a href="https://github.com/PRBonn/MapClosures/blob/main/"><img src="https://img.shields.io/badge/Windows-0078D6?st&logo=windows&logoColor=white" /></a>
7+
<a href="https://github.com/PRBonn/MapClosures/blob/main/"><img src="https://img.shields.io/badge/mac%20os-000000?&logo=apple&logoColor=white" /></a>
68
<br />
79
<br />
810
<span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
@@ -53,18 +55,8 @@ target_link_libraries(my_target PUBLIC map_closures)
5355
```
5456

5557
## Install the Python API and CLI
56-
1. First, install the necessary system dependencies
57-
```sh
58-
sudo apt-get install --no-install-recommends -y build-essential cmake pybind11-dev libeigen3-dev libopencv-dev libtbb-dev
59-
```
60-
2. To get an odometry estimate in our Python CLI we rely on [KISS-ICP](https://github.com/PRBonn/kiss-icp), you can install it using
61-
```sh
62-
pip install kiss-icp
63-
```
64-
3. Then run:
65-
```sh
66-
make
67-
```
58+
`pip install map-closures`
59+
6860
### Usage
6961
<details>
7062
<summary>

cpp/3rdparty/opencv/opencv.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ set(BUILD_opencv_features2d ON CACHE BOOL "Build OpenCV features2d module")
2525
set(BUILD_opencv_imgproc ON CACHE BOOL "Build OpenCV imgproc module")
2626

2727
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libraries")
28+
set(BUILD_WITH_STATIC_CRT OFF CACHE BOOL "Build with statically linked CRT")
2829
set(BUILD_JAVA OFF CACHE BOOL "Build Java bindings")
2930
set(BUILD_PERF_TESTS OFF CACHE BOOL "Build performance tests")
3031
set(BUILD_PROTOBUF OFF CACHE BOOL "Build protobuf")
@@ -49,6 +50,7 @@ set(BUILD_opencv_python_tests OFF CACHE BOOL "Build OpenCV Python tests")
4950
set(BUILD_opencv_stitching OFF CACHE BOOL "Build OpenCV stitching module")
5051
set(BUILD_opencv_video OFF CACHE BOOL "Build OpenCV video module")
5152
set(BUILD_opencv_videoio OFF CACHE BOOL "Build OpenCV video IO module")
53+
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "CMake build type")
5254

5355
message(STATUS "Fetching OpenCV from Github")
5456
include(FetchContent)

cpp/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
# SOFTWARE.
2323

2424
cmake_minimum_required(VERSION 3.16...3.26)
25-
project(map_closures_cpp VERSION 1.0.0 LANGUAGES CXX)
25+
project(map_closures_cpp VERSION 1.0.1 LANGUAGES CXX)
2626

2727
option(USE_SYSTEM_EIGEN3 "Use system pre-installed Eigen" ON)
2828
option(USE_SYSTEM_TBB "Use system pre-installed TBB" ON)
@@ -33,6 +33,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
3333
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
3434

3535
include(3rdparty/find_dependencies.cmake)
36+
include(cmake/CompilerOptions.cmake)
3637

3738
add_subdirectory(map_closures)
3839
add_subdirectory(gt_closures)

cpp/cmake/CompilerOptions.cmake

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# MIT License
2+
#
3+
# Copyright (c) 2022 Ignacio Vizzo, Tiziano Guadagnino, Benedikt Mersch, Cyrill
4+
# Stachniss.
5+
#
6+
# Permission is hereby granted, free of charge, to any person obtaining a copy
7+
# of this software and associated documentation files (the "Software"), to deal
8+
# in the Software without restriction, including without limitation the rights
9+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
# copies of the Software, and to permit persons to whom the Software is
11+
# furnished to do so, subject to the following conditions:
12+
#
13+
# The above copyright notice and this permission notice shall be included in all
14+
# copies or substantial portions of the Software.
15+
#
16+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
# SOFTWARE.
23+
function(set_global_target_properties target)
24+
target_compile_features(${target} PUBLIC cxx_std_17)
25+
target_compile_definitions(${target} PUBLIC $<$<COMPILE_LANG_AND_ID:CXX,MSVC>:_USE_MATH_DEFINES>)
26+
target_compile_options(
27+
${target}
28+
PRIVATE # MSVC
29+
$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/W4>
30+
# Clang/AppleClang
31+
$<$<COMPILE_LANG_AND_ID:CXX,Clang,AppleClang>:-fcolor-diagnostics>
32+
$<$<COMPILE_LANG_AND_ID:CXX,Clang,AppleClang>:-Wall>
33+
$<$<COMPILE_LANG_AND_ID:CXX,Clang,AppleClang>:-Wextra>
34+
$<$<COMPILE_LANG_AND_ID:CXX,Clang,AppleClang>:-Wconversion>
35+
$<$<COMPILE_LANG_AND_ID:CXX,Clang,AppleClang>:-Wno-sign-conversion>
36+
# GNU
37+
$<$<COMPILE_LANG_AND_ID:CXX,GNU>:-fdiagnostics-color=always>
38+
$<$<COMPILE_LANG_AND_ID:CXX,GNU>:-Wall>
39+
$<$<COMPILE_LANG_AND_ID:CXX,GNU>:-Wextra>
40+
$<$<COMPILE_LANG_AND_ID:CXX,GNU>:-pedantic>
41+
$<$<COMPILE_LANG_AND_ID:CXX,GNU>:-Wcast-align>
42+
$<$<COMPILE_LANG_AND_ID:CXX,GNU>:-Wcast-qual>
43+
$<$<COMPILE_LANG_AND_ID:CXX,GNU>:-Wconversion>
44+
$<$<COMPILE_LANG_AND_ID:CXX,GNU>:-Wdisabled-optimization>
45+
$<$<COMPILE_LANG_AND_ID:CXX,GNU>:-Woverloaded-virtual>)
46+
set(INCLUDE_DIRS ${PROJECT_SOURCE_DIR})
47+
get_filename_component(INCLUDE_DIRS ${INCLUDE_DIRS} PATH)
48+
target_include_directories(
49+
${target} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
50+
PUBLIC $<BUILD_INTERFACE:${INCLUDE_DIRS}> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
51+
endfunction()

cpp/gt_closures/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ add_library(gt_closures STATIC)
2525
target_sources(gt_closures PRIVATE VoxelHashSet.cpp GTClosures.cpp)
2626
target_include_directories(gt_closures PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/..)
2727
target_link_libraries(gt_closures PUBLIC Eigen3::Eigen TBB::tbb tsl::robin_map)
28-
target_compile_features(gt_closures PUBLIC cxx_std_17)
28+
set_global_target_properties(gt_closures)

cpp/gt_closures/GTClosures.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ int GTClosures::GetSegments() {
8888
last_pose = poses_.at(idx);
8989
scan_occupancies_.erase(idx);
9090
});
91-
return segments_.size() - n_skip_segments_;
91+
return static_cast<int>(segments_.size()) - n_skip_segments_;
9292
}
9393

9494
std::vector<Eigen::Vector2i> GTClosures::ComputeClosuresForQuerySegment(

cpp/gt_closures/VoxelHashSet.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ struct VoxelHashSet {
4646
const Eigen::Vector3d &t);
4747
void AddVoxels(const VoxelHashSet &other_set);
4848
double ComputeOverlap(const VoxelHashSet &other_set);
49-
int size() const { return set_.size(); }
49+
std::size_t size() const { return set_.size(); }
5050
void clear() { set_.clear(); }
5151

5252
double voxel_size_;

0 commit comments

Comments
 (0)