Skip to content

Commit 4e8e3e8

Browse files
make install of lanelet2 optional
1 parent daef4c7 commit 4e8e3e8

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

.gitlab-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ create_doc:
4848
stage: test
4949
before_script:
5050
- apt-get update -q -y && apt-get install -y libgl1-mesa-dev
51-
- uv pip install --system -e .[test]
51+
- uv pip install --system -e .[test,lanelet2]
5252
script:
5353
- pdoc ./omega_prime --html -o docs --force
5454
artifacts:

omega_prime/__init__.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,31 @@
11
__pdoc__ = {}
22
__pdoc__["converters"] = False
33
""" .. include:: ./../README.md """
4+
import importlib.util
5+
import warnings
46
from . import converters, metrics
57
from .map_odr import MapOdr
6-
from .map_lanelet import MapLanelet
78
from .locator import LaneRelation, Locator
89
from .map import Lane, LaneBoundary, Map, MapOsi
910
from .recording import MovingObject, Recording
1011
from importlib.metadata import version
1112

13+
if importlib.util.find_spec("lanelet2") is not None:
14+
from .map_lanelet import MapLanelet
15+
else:
16+
17+
class MapLanelet:
18+
def __init__(self, *args, **kwargs):
19+
warnings.warn(
20+
"lanelet2 is not installed. To use MapLanelet you need to install `lanelet2` with `pip install lanelet2` (only available on linux). If you are using windows and python <= 3.12 you can try to install `lanelet2x` instead."
21+
)
22+
23+
def __getattr__(self, name):
24+
raise RuntimeError(
25+
f"Cannot use attribute '{name}', since lanelet2 is not installed. To use MapLanelet you need to install `lanelet2` with `pip install lanelet2` (only available on linux). If you are using windows and python <= 3.12 you can try to install `lanelet2x` instead."
26+
)
27+
28+
1229
__version__ = version("omega_prime")
1330

1431
__all__ = [
@@ -18,8 +35,8 @@
1835
"Map",
1936
"Lane",
2037
"LaneBoundary",
21-
"MapOdr",
2238
"MapLanelet",
39+
"MapOdr",
2340
"Locator",
2441
"LaneRelation",
2542
"converters",

pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ dependencies = [
4343
'lxd-io>=0.4.6',
4444
'pyxodr-omega-prime',
4545
'joblib',
46-
'tqdm_joblib',
47-
'lanelet2x'
46+
'tqdm_joblib'
4847
]
4948
version = "0.1.17"
5049

@@ -54,6 +53,8 @@ Repository = "https://github.com/ika-rwth-aachen/omega-prime"
5453

5554
[project.optional-dependencies]
5655
test = ['ruff', 'pdoc3', 'pre-commit', 'pytest', 'pytest-sugar', 'pytest-env','pytest-cov','pytest-progress','pytest-codeblocks', 'nbval','ipywidgets']
56+
lanelet2 = ['lanelet2']
57+
lanelet2x = ['lanelet2x']
5758

5859
[project.scripts]
5960
omega-prime = "omega_prime.cli:main"

0 commit comments

Comments
 (0)