Different install types for Python scripts

asked 2020-09-08 17:32:06 -0500

maydin gravatar image

updated 2022-01-22 16:16:17 -0500

Evgeny gravatar image

I want to use 2 different configuration for devel and install types for my Python scripts.

I have a main.py in src/scripts and that script depend on several subpackages in app package. Directory structure like this:

src/
-- CMakeLists.txt
-- setup.py
-- scripts/
---- main.py
---- app/
------ __init__.py
------ module1.py

If I put catkin_python_setup() line and configure setup.py it copies related Python files and it works.

But for install build configuration, I don't want to copy .py files. I want to hide my source code so I just want to copy .pyc files. I can execute my bash script to do this using following CMake entry but it doesn't refresh if I modify a file. Therefore I want a better solution for this. For now I have to clean build and rebuild again after a change in my Python files.

execute_process (
    COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/scripts/copy_pyc_files.sh 
    ${CMAKE_INSTALL_PREFIX}/${CATKIN_PACKAGE_SHARE_DESTINATION}/scripts
    OUTPUT_VARIABLE setup_return
)
edit retag flag offensive close merge delete