Skip to content

Commit dd75afc

Browse files
committed
Make stub generation optioanl
1 parent 194756d commit dd75afc

File tree

3 files changed

+23
-13
lines changed

3 files changed

+23
-13
lines changed

CMakeLists.txt

+15-12
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,22 @@ install(TARGETS behaviortree_py example
6060
# ##############################################################################
6161
# ################## Generate and install Python stubs #########################
6262
# ##############################################################################
63-
add_custom_command(
64-
TARGET behaviortree_py
65-
POST_BUILD
66-
COMMAND stubgen --output $<TARGET_FILE_DIR:behaviortree_py> -p behaviortree_py
67-
-v --verbose
68-
WORKING_DIRECTORY $<TARGET_FILE_DIR:behaviortree_py>
69-
USES_TERMINAL)
63+
find_program(STUBGEN_EXECUTABLE stubgen)
64+
if(STUBGEN_EXECUTABLE)
65+
add_custom_command(
66+
TARGET behaviortree_py
67+
POST_BUILD
68+
COMMAND stubgen --output $<TARGET_FILE_DIR:behaviortree_py> -p
69+
behaviortree_py -v --verbose
70+
WORKING_DIRECTORY $<TARGET_FILE_DIR:behaviortree_py>
71+
USES_TERMINAL)
7072

71-
install(
72-
FILES
73-
$<TARGET_FILE_DIR:behaviortree_py>/$<TARGET_FILE_BASE_NAME:behaviortree_py>.pyi
74-
COMPONENT python
75-
DESTINATION ${PYTHON_INSTALL_DIR}/$<TARGET_FILE_BASE_NAME:behaviortree_py>)
73+
install(
74+
FILES
75+
$<TARGET_FILE_DIR:behaviortree_py>/$<TARGET_FILE_BASE_NAME:behaviortree_py>.pyi
76+
COMPONENT python
77+
DESTINATION ${PYTHON_INSTALL_DIR}/$<TARGET_FILE_BASE_NAME:behaviortree_py>)
78+
endif()
7679

7780
ament_export_targets(${PROJECT_NAME}Targets HAS_LIBRARY_TARGET)
7881
ament_export_dependencies(behaviortree_cpp pybind11_vendor fmt py_binding_tools

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ bt.load_type_converters(
4040
...
4141
```
4242

43+
## Stubs generation
44+
45+
If you want the stubs to be generated, you need to install the package `mypy`:
46+
47+
```bash
48+
sudo apt install mypy
49+
```
50+
4351
## Limitations
4452

4553
- Only `register_simple_action`, `register_simple_condition`, and `register_simple_decorator` are currently supported.

package.xml

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
<depend>behaviortree_cpp</depend>
1313
<depend>py_binding_tools</depend>
14-
<depend>python3-mypy</depend>
1514
<depend>fmt</depend>
1615

1716
<export>

0 commit comments

Comments
 (0)