Skip to content

Commit

Permalink
Change python files installation (#348)
Browse files Browse the repository at this point in the history
Signed-off-by: Ricardo González Moreno <[email protected]>
  • Loading branch information
richiware authored May 24, 2024
1 parent 5efa58d commit 57db6d9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,15 @@ import "com/eprosima/fastdds/idl/templates/eprosima.stg"
main(ctx, definitions) ::= <<
$fileHeader(ctx=ctx, file=[ctx.filename, ".i"], description=["This header file contains the SWIG interface of the described types in the IDL file."])$

%module $ctx.filename$
%module(moduleimport="if __import__('os').name == 'nt': import win32api; win32api.LoadLibrary('$ctx.filename$.dll')\nif __package__ or '.' in __name__:\n from . import _$ctx.filename$Wrapper\nelse:\n import _$ctx.filename$Wrapper") $ctx.filename$

// If using windows in debug, it would try to use python_d, which would not be found.
%begin %{
#ifdef _MSC_VER
#define SWIG_PYTHON_INTERPRETER_NO_DEBUG
#endif
#include <exception>
%}

// SWIG helper modules
%include "stdint.i"
Expand Down
13 changes: 3 additions & 10 deletions src/main/java/com/eprosima/fastdds/idl/templates/SwigCMake.stg
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ SET_SOURCE_FILES_PROPERTIES(
USE_TARGET_INCLUDE_DIRECTORIES TRUE
)

set_property(SOURCE \${PROJECT_NAME}.i PROPERTY OUTPUT_DIR "\${CMAKE_CURRENT_BINARY_DIR}/$project.context.lastStructure.typeCode.namespaces : { ns | $ns$}; separator="/"$")

SWIG_ADD_LIBRARY(\${\${PROJECT_NAME}_MODULE}
TYPE SHARED
LANGUAGE python
Expand All @@ -114,11 +112,6 @@ target_link_libraries(\${\${PROJECT_NAME}_MODULE}
\${PROJECT_NAME}
)

set_target_properties(\${\${PROJECT_NAME}_MODULE}
PROPERTIES LIBRARY_OUTPUT_DIRECTORY "\${CMAKE_CURRENT_BINARY_DIR}/$project.context.lastStructure.typeCode.namespaces : { ns | $ns$}; separator="/"$"
)


# Find the installation path
execute_process(COMMAND \${PYTHON_EXECUTABLE} -c "from distutils import sysconfig; print(sysconfig.get_python_lib(plat_specific=True, prefix='\${CMAKE_INSTALL_PREFIX}'))"
OUTPUT_VARIABLE _ABS_PYTHON_MODULE_PATH
Expand All @@ -128,7 +121,7 @@ execute_process(COMMAND \${PYTHON_EXECUTABLE} -c "from distutils import sysconfi
get_filename_component (_ABS_PYTHON_MODULE_PATH \${_ABS_PYTHON_MODULE_PATH} ABSOLUTE)
file (RELATIVE_PATH _REL_PYTHON_MODULE_PATH \${CMAKE_INSTALL_PREFIX} \${_ABS_PYTHON_MODULE_PATH})
SET (PYTHON_MODULE_PATH
\${_REL_PYTHON_MODULE_PATH}
\${_REL_PYTHON_MODULE_PATH}$project.context.lastStructure.typeCode.namespaces : { ns | /$ns$}$/\${PROJECT_NAME}
)

# Install
Expand All @@ -137,8 +130,8 @@ install(TARGETS \${PROJECT_NAME}
LIBRARY DESTINATION lib/
ARCHIVE DESTINATION lib/
)
install(TARGETS \${\${PROJECT_NAME}_MODULE} DESTINATION \${PYTHON_MODULE_PATH}/$project.context.lastStructure.typeCode.namespaces : { ns | $ns$}; separator="/"$)
install(TARGETS \${\${PROJECT_NAME}_MODULE} DESTINATION \${PYTHON_MODULE_PATH})
get_property(support_files TARGET \${\${PROJECT_NAME}_MODULE} PROPERTY SWIG_SUPPORT_FILES)
install(FILES \${support_files} DESTINATION \${PYTHON_MODULE_PATH}/$project.context.lastStructure.typeCode.namespaces : { ns | $ns$}; separator="/"$)
install(FILES \${support_files} DESTINATION \${PYTHON_MODULE_PATH} RENAME __init__.py)

>>

0 comments on commit 57db6d9

Please sign in to comment.