-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add catkin support * Rename genpy_stubgen to genpyi * Update README
- Loading branch information
1 parent
fec7afc
commit 6914e3e
Showing
6 changed files
with
151 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
cmake_minimum_required(VERSION 3.0.2) | ||
project(genpyi) | ||
find_package(catkin REQUIRED COMPONENTS genmsg genpy) | ||
|
||
catkin_package( | ||
CATKIN_DEPENDS genmsg genpy | ||
CFG_EXTRAS genpyi-extras.cmake | ||
) | ||
|
||
add_subdirectory(scripts) | ||
|
||
file(WRITE ${CATKIN_DEVEL_PREFIX}/${GENMSG_LANGS_DESTINATION}/genpyi "Python Stub") | ||
install(FILES ${CATKIN_DEVEL_PREFIX}/${GENMSG_LANGS_DESTINATION}/genpyi | ||
DESTINATION ${GENMSG_LANGS_DESTINATION}) | ||
|
||
catkin_python_setup() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
@[if DEVELSPACE]@ | ||
# location of scripts in develspace | ||
set(GENPYI_DIR "@(CMAKE_CURRENT_SOURCE_DIR)/scripts") | ||
@[else]@ | ||
# location of scripts in installspace | ||
set(GENPYI_DIR "${genpyi_DIR}/../../../@(CATKIN_PACKAGE_BIN_DESTINATION)") | ||
@[end if]@ | ||
|
||
set(GENPYI_BIN ${GENPYI_DIR}/run_genpyi.py) | ||
|
||
macro(_generate_genpyi ARG_KIND ARG_PKG ARG_FILE ARG_IFLAGS ARG_MSG_DEPS ARG_GEN_OUTPUT_DIR) | ||
file(MAKE_DIRECTORY ${ARG_GEN_OUTPUT_DIR}) | ||
|
||
# in order to get output file path | ||
get_filename_component(FILE_NAME ${ARG_FILE} NAME) | ||
get_filename_component(FILE_SHORT_NAME ${ARG_FILE} NAME_WE) | ||
|
||
set(GENERATED_FILE_NAME _${FILE_SHORT_NAME}.pyi) | ||
set(GEN_OUTPUT_FILE ${ARG_GEN_OUTPUT_DIR}/${GENERATED_FILE_NAME}) | ||
|
||
add_custom_command(OUTPUT ${GEN_OUTPUT_FILE} | ||
DEPENDS ${GENPYI_BIN} ${ARG_FILE} ${ARG_MSG_DEPS} | ||
COMMAND ${CATKIN_ENV} ${PYTHON_EXECUTABLE} ${GENPYI_BIN} ${ARG_KIND} ${ARG_PKG} | ||
--out-dir ${ARG_GEN_OUTPUT_DIR} | ||
${ARG_IFLAGS} | ||
${ARG_FILE} | ||
COMMENT "Generating Python Stub from ${ARG_PKG}/${FILE_SHORT_NAME}" | ||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" | ||
) | ||
|
||
list(APPEND ALL_GEN_OUTPUT_FILES_pyi ${GEN_OUTPUT_FILE}) | ||
|
||
endmacro() | ||
|
||
macro(_generate_msg_pyi ARG_PKG ARG_MSG ARG_IFLAGS ARG_MSG_DEPS ARG_GEN_OUTPUT_DIR) | ||
_generate_genpyi("msg" ${ARG_PKG} ${ARG_MSG} "${ARG_IFLAGS}" "${ARG_MSG_DEPS}" "${ARG_GEN_OUTPUT_DIR}/msg") | ||
endmacro() | ||
|
||
macro(_generate_srv_pyi ARG_PKG ARG_SRV ARG_IFLAGS ARG_MSG_DEPS ARG_GEN_OUTPUT_DIR) | ||
_generate_genpyi("srv" ${ARG_PKG} ${ARG_SRV} "${ARG_IFLAGS}" "${ARG_MSG_DEPS}" "${ARG_GEN_OUTPUT_DIR}/srv") | ||
endmacro() | ||
|
||
macro(_generate_module_pyi ARG_PKG ARG_GEN_OUTPUT_DIR ARG_GENERATED_FILES) | ||
# place an empty __init__.pyi in the parent folder of msg/srv | ||
if(NOT EXISTS ${ARG_GEN_OUTPUT_DIR}/__init__.pyi) | ||
file(WRITE ${ARG_GEN_OUTPUT_DIR}/__init__.pyi "") | ||
endif() | ||
|
||
foreach(type "msg" "srv") | ||
set(GEN_OUTPUT_DIR "${ARG_GEN_OUTPUT_DIR}/${type}") | ||
set(GEN_OUTPUT_FILE ${GEN_OUTPUT_DIR}/__init__.pyi) | ||
|
||
if(IS_DIRECTORY ${GEN_OUTPUT_DIR}) | ||
add_custom_command(OUTPUT ${GEN_OUTPUT_FILE} | ||
DEPENDS ${GENPYI_BIN} | ||
COMMAND ${CATKIN_ENV} ${PYTHON_EXECUTABLE} ${GENPYI_BIN} module | ||
--module-finder py | ||
--out-dir ${GEN_OUTPUT_DIR} | ||
${GEN_OUTPUT_DIR} | ||
COMMENT "Generating Python Stub ${type} __init__.pyi for ${ARG_PKG}" | ||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" | ||
) | ||
list(APPEND ALL_GEN_OUTPUT_FILES_pyi ${GEN_OUTPUT_FILE}) | ||
endif() | ||
|
||
endforeach() | ||
|
||
endmacro() | ||
|
||
# {lang}_INSTALL_DIR is to control ARG_GEN_OUTPUT_DIR | ||
# See: https://github.com/ros/genmsg/blob/7d8b6ce6f43b6e39ea8261125d270f2d3062356f/cmake/pkg-genmsg.cmake.em#L85-L96 | ||
if(NOT EXISTS @(PROJECT_NAME)_SOURCE_DIR) | ||
set(genpyi_INSTALL_DIR ${PYTHON_INSTALL_DIR}) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?xml version="1.0"?> | ||
<?xml-model | ||
href="http://download.ros.org/schema/package_format3.xsd" | ||
schematypens="http://www.w3.org/2001/XMLSchema"?> | ||
<package format="3"> | ||
<name>genpyi</name> | ||
<version>0.0.1</version> | ||
<description> | ||
Python stub generator from genmsg specs | ||
</description> | ||
<maintainer email="[email protected]">Yuki Igarashi</maintainer> | ||
<maintainer email="[email protected]">Tamaki Nishino</maintainer> | ||
<license>Apache</license> | ||
|
||
<url type="website">https://github.com/rospypi/genpy_stubgen</url> | ||
<url type="bugtracker">https://github.com/rospypi/genpy_stubgen/issues</url> | ||
<url type="repository">https://github.com/rospypi/genpy_stubgen</url> | ||
|
||
<author>Yuki Igarashi</author> | ||
<author>Tamaki Nishino</author> | ||
|
||
<depend>genmsg</depend> | ||
<depend>genpy</depend> | ||
|
||
<buildtool_depend version_gte="0.5.74">catkin</buildtool_depend> | ||
<buildtool_depend condition="$ROS_PYTHON_VERSION == 2">python-setuptools</buildtool_depend> | ||
<buildtool_depend condition="$ROS_PYTHON_VERSION == 3">python3-setuptools</buildtool_depend> | ||
|
||
<export> | ||
<message_generator>pyi</message_generator> | ||
<architecture_independent/> | ||
</export> | ||
</package> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
catkin_install_python( | ||
PROGRAMS run_genpyi.py | ||
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env python | ||
from genpy_stubgen.cli import cli | ||
|
||
|
||
if __name__ == "__main__": | ||
cli() |