Skip to content

Commit

Permalink
Rename genpy_stubgen to genpyi
Browse files Browse the repository at this point in the history
  • Loading branch information
bonprosoft committed Apr 27, 2021
1 parent e9b85a7 commit afbc3c5
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 25 deletions.
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
cmake_minimum_required(VERSION 3.0.2)
project(genpy_stubgen)
project(genpyi)
find_package(catkin REQUIRED COMPONENTS genmsg genpy)

catkin_package(
CATKIN_DEPENDS genmsg genpy
CFG_EXTRAS genpy-stubgen-extras.cmake
CFG_EXTRAS genpyi-extras.cmake
)

add_subdirectory(scripts)

file(WRITE ${CATKIN_DEVEL_PREFIX}/${GENMSG_LANGS_DESTINATION}/genpy_stubgen "Python stub")
install(FILES ${CATKIN_DEVEL_PREFIX}/${GENMSG_LANGS_DESTINATION}/genpy_stubgen
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()
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
@[if DEVELSPACE]@
# location of scripts in develspace
set(GENPY_STUBGEN_DIR "@(CMAKE_CURRENT_SOURCE_DIR)/scripts")
set(GENPYI_DIR "@(CMAKE_CURRENT_SOURCE_DIR)/scripts")
@[else]@
# location of scripts in installspace
set(GENPY_STUBGEN_DIR "${genpy_stubgen_DIR}/../../../@(CATKIN_PACKAGE_BIN_DESTINATION)")
set(GENPYI_DIR "${genpyi_DIR}/../../../@(CATKIN_PACKAGE_BIN_DESTINATION)")
@[end if]@

set(GENPY_STUBGEN_BIN ${GENPY_STUBGEN_DIR}/run_genpy_stubgen.py)
set(GENPYI_BIN ${GENPYI_DIR}/run_genpyi.py)

macro(_generate_genpy_stub ARG_KIND ARG_PKG ARG_FILE ARG_IFLAGS ARG_MSG_DEPS ARG_GEN_OUTPUT_DIR)
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
Expand All @@ -19,28 +19,28 @@ macro(_generate_genpy_stub ARG_KIND ARG_PKG ARG_FILE ARG_IFLAGS ARG_MSG_DEPS ARG
set(GEN_OUTPUT_FILE ${ARG_GEN_OUTPUT_DIR}/${GENERATED_FILE_NAME})

add_custom_command(OUTPUT ${GEN_OUTPUT_FILE}
DEPENDS ${GENPY_STUBGEN_BIN} ${ARG_FILE} ${ARG_MSG_DEPS}
COMMAND ${CATKIN_ENV} ${PYTHON_EXECUTABLE} ${GENPY_STUBGEN_BIN} ${ARG_KIND} ${ARG_PKG}
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 (pyi) from ${ARG_PKG}/${FILE_SHORT_NAME}"
COMMENT "Generating Python Stub from ${ARG_PKG}/${FILE_SHORT_NAME}"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
)

list(APPEND ALL_GEN_OUTPUT_FILES_py_stubgen ${GEN_OUTPUT_FILE})
list(APPEND ALL_GEN_OUTPUT_FILES_pyi ${GEN_OUTPUT_FILE})

endmacro()

macro(_generate_msg_py_stubgen ARG_PKG ARG_MSG ARG_IFLAGS ARG_MSG_DEPS ARG_GEN_OUTPUT_DIR)
_generate_genpy_stub("msg" ${ARG_PKG} ${ARG_MSG} "${ARG_IFLAGS}" "${ARG_MSG_DEPS}" "${ARG_GEN_OUTPUT_DIR}/msg")
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_py_stubgen ARG_PKG ARG_SRV ARG_IFLAGS ARG_MSG_DEPS ARG_GEN_OUTPUT_DIR)
_generate_genpy_stub("srv" ${ARG_PKG} ${ARG_SRV} "${ARG_IFLAGS}" "${ARG_MSG_DEPS}" "${ARG_GEN_OUTPUT_DIR}/srv")
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_py_stubgen ARG_PKG ARG_GEN_OUTPUT_DIR ARG_GENERATED_FILES)
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 "")
Expand All @@ -52,15 +52,15 @@ macro(_generate_module_py_stubgen ARG_PKG ARG_GEN_OUTPUT_DIR ARG_GENERATED_FILES

if(IS_DIRECTORY ${GEN_OUTPUT_DIR})
add_custom_command(OUTPUT ${GEN_OUTPUT_FILE}
DEPENDS ${GENPY_STUBGEN_BIN}
COMMAND ${CATKIN_ENV} ${PYTHON_EXECUTABLE} ${GENPY_STUBGEN_BIN} module
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 ${type} __init__.pyi for ${ARG_PKG}"
COMMENT "Generating Python Stub ${type} __init__.pyi for ${ARG_PKG}"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
)
list(APPEND ALL_GEN_OUTPUT_FILES_py_stubgen ${GEN_OUTPUT_FILE})
list(APPEND ALL_GEN_OUTPUT_FILES_pyi ${GEN_OUTPUT_FILE})
endif()

endforeach()
Expand All @@ -70,5 +70,5 @@ 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(genpy_stubgen_INSTALL_DIR ${PYTHON_INSTALL_DIR})
set(genpyi_INSTALL_DIR ${PYTHON_INSTALL_DIR})
endif()
4 changes: 2 additions & 2 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
href="http://download.ros.org/schema/package_format3.xsd"
schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>genpy_stubgen</name>
<name>genpyi</name>
<version>0.0.1</version>
<description>
Python stub generator from genmsg specs
Expand All @@ -27,7 +27,7 @@
<buildtool_depend condition="$ROS_PYTHON_VERSION == 3">python3-setuptools</buildtool_depend>

<export>
<message_generator>py_stubgen</message_generator>
<message_generator>pyi</message_generator>
<architecture_independent/>
</export>
</package>
2 changes: 1 addition & 1 deletion scripts/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
catkin_install_python(
PROGRAMS run_genpy_stubgen.py
PROGRAMS run_genpyi.py
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
File renamed without changes.

0 comments on commit afbc3c5

Please sign in to comment.