Skip to content

Commit

Permalink
feat: build wheel
Browse files Browse the repository at this point in the history
  • Loading branch information
wu-vincent committed Nov 22, 2023
1 parent 45ba2ec commit 6a947aa
Show file tree
Hide file tree
Showing 20 changed files with 219 additions and 202 deletions.
6 changes: 4 additions & 2 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from conan import ConanFile
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps

from lanelet2_python.src.lanelet2 import __version__


class Lanelet2Conan(ConanFile):
name = "lanelet2x"
version = "1.2.1"
version = __version__

# Optional metadata
license = "BSD"
Expand All @@ -19,7 +21,7 @@ class Lanelet2Conan(ConanFile):
default_options = {
"shared": False,
"fPIC": True,
# "boost/*:shared": True,
"boost/*:shared": True,
"boost/*:without_python": False,
}

Expand Down
18 changes: 10 additions & 8 deletions lanelet2_core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,16 @@ target_link_libraries(${PROJECT_NAME} PUBLIC Boost::headers Eigen3::Eigen)
## Install ##
#############
# Install all targets, headers by default and scripts and other files if specified (folders or files).
include(GNUInstallDirs)
install(TARGETS ${PROJECT_NAME}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(DIRECTORY doc/ DESTINATION "doc/${PROJECT_NAME}")
install(DIRECTORY scripts/ DESTINATION "scripts/")
if (NOT DEFINED SKBUILD)
include(GNUInstallDirs)
install(TARGETS ${PROJECT_NAME}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(DIRECTORY doc/ DESTINATION "doc/${PROJECT_NAME}")
install(DIRECTORY scripts/ DESTINATION "scripts/")
endif ()

#############
## Testing ##
Expand Down
14 changes: 8 additions & 6 deletions lanelet2_io/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ target_link_libraries(${PROJECT_NAME} PUBLIC lanelet2_core Boost::filesystem Boo
## Install ##
#############
# Install all targets, headers by default and scripts and other files if specified (folders or files).
include(GNUInstallDirs)
install(TARGETS ${PROJECT_NAME}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
if (NOT DEFINED SKBUILD)
include(GNUInstallDirs)
install(TARGETS ${PROJECT_NAME}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
endif ()

#############
## Testing ##
Expand Down
6 changes: 4 additions & 2 deletions lanelet2_maps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@ add_custom_command(
#############
# Install all targets, headers by default and scripts and other files if specified (folders or files).
# This command also exports libraries and config files for dependent packages and this supersedes catkin_package.
install(DIRECTORY res/ DESTINATION "res/")
install(DIRECTORY josm/ DESTINATION "res/" PATTERN ".gitignore" EXCLUDE)
if (NOT DEFINED SKBUILD)
install(DIRECTORY res/ DESTINATION "res/")
install(DIRECTORY josm/ DESTINATION "res/" PATTERN ".gitignore" EXCLUDE)
endif ()
14 changes: 8 additions & 6 deletions lanelet2_matching/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ target_link_libraries(${PROJECT_NAME} PUBLIC lanelet2_core lanelet2_io lanelet2_
## Install ##
#############
# Install all targets, headers by default and scripts and other files if specified (folders or files).
include(GNUInstallDirs)
install(TARGETS ${PROJECT_NAME}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
if (NOT DEFINED SKBUILD)
include(GNUInstallDirs)
install(TARGETS ${PROJECT_NAME}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
endif ()

#############
## Testing ##
Expand Down
16 changes: 9 additions & 7 deletions lanelet2_projection/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ target_link_libraries(${PROJECT_NAME} PUBLIC lanelet2_core lanelet2_io Geographi
## Install ##
#############
# Install all targets, headers by default and scripts and other files if specified (folders or files).
include(GNUInstallDirs)
install(TARGETS ${PROJECT_NAME}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(DIRECTORY doc/ DESTINATION "doc/${PROJECT_NAME}")
if (NOT DEFINED SKBUILD)
include(GNUInstallDirs)
install(TARGETS ${PROJECT_NAME}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(DIRECTORY doc/ DESTINATION "doc/${PROJECT_NAME}")
endif ()

#############
## Testing ##
Expand Down
15 changes: 12 additions & 3 deletions lanelet2_python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ set(PROJECT_PYTHON_TARGETS)
file(GLOB PROJECT_PYTHON_SOURCE_FILES_SRC "${CMAKE_CURRENT_SOURCE_DIR}/python_api/*.cpp")
foreach (PROJECT_PYTHON_SOURCE_FILE ${PROJECT_PYTHON_SOURCE_FILES_SRC})
get_filename_component(PYTHON_MODULE_NAME ${PROJECT_PYTHON_SOURCE_FILE} NAME_WE)
Python_add_library(${PYTHON_MODULE_NAME} MODULE ${PROJECT_PYTHON_SOURCE_FILE} WITH_SOABI)
python_add_library(${PYTHON_MODULE_NAME} MODULE ${PROJECT_PYTHON_SOURCE_FILE} WITH_SOABI)
target_compile_definitions(${PYTHON_MODULE_NAME} PRIVATE -DPYTHON_API_MODULE_NAME=${PYTHON_MODULE_NAME})
target_include_directories(${PYTHON_MODULE_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
target_include_directories(${PYTHON_MODULE_NAME} PRIVATE ${Python3_INCLUDE_DIRS})
target_link_libraries(${PYTHON_MODULE_NAME} PUBLIC Boost::python lanelet2_core lanelet2_io lanelet2_projection lanelet2_traffic_rules lanelet2_routing lanelet2_matching)
Expand All @@ -24,8 +25,16 @@ endforeach ()
#############
## Install ##
#############
# Install all targets, headers by default and scripts and other files if specified (folders or files).
install(TARGETS ${PROJECT_PYTHON_TARGETS} DESTINATION lanelet2)
# Install all python modules into /lanelet2 if CMake is running inside scikit-build-core
if (DEFINED SKBUILD)
install(TARGETS ${PROJECT_PYTHON_TARGETS} DESTINATION "lanelet2")
if (WIN32)
# Bundle runtime dlls with the wheel on windows
foreach (PROJECT_PYTHON_TARGET ${PROJECT_PYTHON_TARGETS})
install(FILES "$<TARGET_RUNTIME_DLLS:${PROJECT_PYTHON_TARGET}>" DESTINATION "lanelet2/bin")
endforeach ()
endif ()
endif ()

#############
## Testing ##
Expand Down
29 changes: 0 additions & 29 deletions lanelet2_python/package.xml

This file was deleted.

22 changes: 12 additions & 10 deletions lanelet2_python/scripts/create_debug_routing_graph.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env python

import lanelet2
import sys
import argparse

import lanelet2

if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("filename", help="Path to the input osm file")
Expand All @@ -13,21 +13,23 @@
help="traffic participant type (one of vehicle, bicycle, pedestrian, train",
type=str,
required=True,
default="vehicle")
default="vehicle",
)
parser.add_argument("--lat", help="Lateral position of origin", type=float, default=49)
parser.add_argument("--lon", help="Longitudinal position of origin", type=float, default=8)
args = parser.parse_args()

rules_map = {"vehicle": lanelet2.traffic_rules.Participants.Vehicle,
"bicycle": lanelet2.traffic_rules.Participants.Bicycle,
"pedestrian": lanelet2.traffic_rules.Participants.Pedestrian,
"train": lanelet2.traffic_rules.Participants.Train}
rules_map = {
"vehicle": lanelet2.traffic_rules.Participants.Vehicle,
"bicycle": lanelet2.traffic_rules.Participants.Bicycle,
"pedestrian": lanelet2.traffic_rules.Participants.Pedestrian,
"train": lanelet2.traffic_rules.Participants.Train,
}
proj = lanelet2.projection.UtmProjector(lanelet2.io.Origin(args.lat, args.lon))
laneletmap = lanelet2.io.load(args.filename, proj)

routing_cost = lanelet2.routing.RoutingCostDistance(0.) # zero cost for lane changes
traffic_rules = lanelet2.traffic_rules.create(lanelet2.traffic_rules.Locations.Germany,
rules_map[args.participant])
routing_cost = lanelet2.routing.RoutingCostDistance(0.0) # zero cost for lane changes
traffic_rules = lanelet2.traffic_rules.create(lanelet2.traffic_rules.Locations.Germany, rules_map[args.participant])
graph = lanelet2.routing.RoutingGraph(laneletmap, traffic_rules, [routing_cost])
debug_map = graph.getDebugLaneletMap()

Expand Down
7 changes: 3 additions & 4 deletions lanelet2_python/scripts/make_ids_positive.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env python

import lanelet2
import sys
import argparse

import lanelet2


def make_positive(layer):
for elem in layer:
Expand All @@ -14,7 +14,7 @@ def make_positive(layer):
parser = argparse.ArgumentParser()
parser.add_argument("filename", help="Path to the input osm file")
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument("output", help="Path to results", nargs='?')
group.add_argument("output", help="Path to results", nargs="?")
group.add_argument("-i", "--inplace", action="store_true", help="Overwrite input file")
args = parser.parse_args()

Expand All @@ -24,7 +24,6 @@ def make_positive(layer):
proj = lanelet2.projection.MercatorProjector(lanelet2.io.Origin(49, 8))
map = lanelet2.io.load(args.filename, proj)


make_positive(map.pointLayer)
make_positive(map.lineStringLayer)
make_positive(map.polygonLayer)
Expand Down
15 changes: 11 additions & 4 deletions lanelet2_python/scripts/print_ids.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/env python

import lanelet2
import sys
import argparse
import sys

import lanelet2


def print_layer(layer, layerName):
Expand All @@ -18,8 +19,14 @@ def print_layer(layer, layerName):
proj = lanelet2.projection.MercatorProjector(lanelet2.io.Origin(49, 8))
map = lanelet2.io.load(args.filename, proj)

layers = {"Points": map.pointLayer, "Line Strings": map.lineStringLayer, "Polygons": map.polygonLayer,
"Lanelets": map.laneletLayer, "Areas": map.areaLayer, "Regulatory Elements": map.regulatoryElementLayer}
layers = {
"Points": map.pointLayer,
"Line Strings": map.lineStringLayer,
"Polygons": map.polygonLayer,
"Lanelets": map.laneletLayer,
"Areas": map.areaLayer,
"Regulatory Elements": map.regulatoryElementLayer,
}

for layer_name, layer in layers.iteritems():
if not args.has_id:
Expand Down
38 changes: 0 additions & 38 deletions lanelet2_python/setup.py.template

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
import os
from os.path import dirname
from pkgutil import iter_modules

__version__ = "1.2.1"

if os.name == "nt":
bin_dir = None

try:
bin_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), "bin"))
try:
os.add_dll_directory(bin_dir)
except (Exception,):
pass
os.environ["PATH"] = bin_dir + ";" + os.environ["PATH"]
except (Exception,):
pass

del bin_dir

# automatically import all files in this module
__all__ = [name for _, name, _ in iter_modules([dirname(__file__)])]

Expand Down
Loading

0 comments on commit 6a947aa

Please sign in to comment.