Skip to content

Commit 969f027

Browse files
authored
Don't wrap modules (#7)
* Don't wrap modules * Add flake8 config
1 parent f06c540 commit 969f027

File tree

3 files changed

+34
-20
lines changed

3 files changed

+34
-20
lines changed

ament_cmake_virtualenv/cmake/ament_generate_virtualenv.cmake

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,14 @@ function(ament_generate_virtualenv)
128128
)
129129
130130
131-
# Override the ament_python_install_module macro to wrap modules
132-
find_program(wrap_module_BIN NAMES "wrap_module"
133-
PATHS "${CMAKE_INSTALL_PREFIX}/../ament_virtualenv/bin/")
134-
if(NOT wrap_module_BIN)
135-
message(FATAL_ERROR "could not find program 'wrap_module'")
136-
endif()
137131
macro(ament_python_install_module)
132+
# Override the ament_python_install_module macro to wrap modules
133+
find_program(wrap_module_BIN NAMES "wrap_module"
134+
PATHS "${CMAKE_INSTALL_PREFIX}/../ament_virtualenv/bin/")
135+
if(NOT wrap_module_BIN)
136+
message(FATAL_ERROR "could not find program 'wrap_module'")
137+
endif()
138+
138139
_ament_cmake_python_register_environment_hook()
139140
_ament_cmake_python_install_module(${ARGN})
140141
get_filename_component(module_path ${ARGN} NAME)
@@ -148,22 +149,32 @@ COMMAND ${wrap_module_BIN} --module-path ${module_path} --venv-install-dir ${${P
148149
)
149150
endmacro()
150151
151-
# Override the ament_python_install_package macro to wrap packages
152-
find_program(wrap_package_BIN NAMES "wrap_package"
153-
PATHS "${CMAKE_INSTALL_PREFIX}/../ament_virtualenv/bin/")
154-
if(NOT wrap_package_BIN)
155-
message(FATAL_ERROR "could not find program 'wrap_package'")
156-
endif()
157152
macro(ament_python_install_package)
153+
# Override the ament_python_install_package macro to wrap packages
154+
find_program(wrap_package_BIN NAMES "wrap_package"
155+
PATHS "${CMAKE_INSTALL_PREFIX}/../ament_virtualenv/bin/")
156+
if(NOT wrap_package_BIN)
157+
message(FATAL_ERROR "could not find program 'wrap_package'")
158+
endif()
159+
158160
_ament_cmake_python_register_environment_hook()
159161
_ament_cmake_python_install_package(${ARGN})
162+
163+
set(options "")
164+
set(oneValueArgs "")
165+
set(multiValueArgs SCRIPTS)
166+
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
167+
160168
set(package_dir "${CMAKE_INSTALL_PREFIX}/${PYTHON_INSTALL_DIR}/${ARGN}")
161-
# message(
162-
# WARNING "[ament_cmake_virtualenv]: ament_python_install_package override for ${package_dir} to ${${PROJECT_NAME}_VENV_INSTALL_DIR}"
163-
# )
164-
install(
165-
CODE "execute_process(\
166-
COMMAND ${wrap_package_BIN} --package-dir ${package_dir} --venv-install-dir ${${PROJECT_NAME}_VENV_INSTALL_DIR})"
167-
)
169+
170+
if(ARG_SCRIPTS_DIR)
171+
# message(
172+
# INFO "[ament_cmake_virtualenv]: ament_python_install_package override for ${package_dir} to ${${PROJECT_NAME}_VENV_INSTALL_DIR}"
173+
# )
174+
install(
175+
CODE "execute_process(\
176+
COMMAND ${wrap_package_BIN} --package-dir ${package_dir} --venv-install-dir ${${PROJECT_NAME}_VENV_INSTALL_DIR})"
177+
)
178+
endif()
168179
endmacro()
169180
endfunction()

ament_virtualenv/.flake8

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[flake8]
2+
max-line-length = 88
3+
ignore = Q000,E203,D100

ament_virtualenv/test/test_flake8.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@
1919
@pytest.mark.flake8
2020
@pytest.mark.linter
2121
def test_flake8():
22-
rc = main(argv=[])
22+
rc = main(argv=["--config", ".flake8"])
2323
assert rc == 0, 'Found errors'

0 commit comments

Comments
 (0)