Hey everyone,
I’m confused about python code obfuscation.
This matter was already discussed on the community
But I couldn’t see how to do it. Which CMakeList should I configure? And when this should be executed? I’m not familiar with any kind of module installation/build. I’m running Slicer on Ubuntu 20.04
Some interesting links were provided, such as this one and the following CMakeList code block:
function(replace_py_with_pyc ${SCRIPTED_MODULE_PYCACHE_DIR_PATH})
if (EXISTS ${SCRIPTED_MODULE_PYCACHE_DIR_PATH}/__pycache__ AND IS_DIRECTORY ${SCRIPTED_MODULE_PYCACHE_DIR_PATH}/__pycache__)
message("--- Attempting to copy .pyc files...")
file(GLOB PYC_FILES ${SCRIPTED_MODULE_PYCACHE_DIR_PATH}/__pycache__/*.pyc)
file(COPY ${PYC_FILES} DESTINATION ${SCRIPTED_MODULE_PYCACHE_DIR_PATH}/)
message("--- Attempting to remove .py files...")
file(GLOB PY_FILES ${SCRIPTED_MODULE_PYCACHE_DIR_PATH}/*.py)
file(REMOVE ${PY_FILES})
endif()
file(GLOB SUBDIRS LIST_DIRECTORIES True ${SCRIPTED_MODULE_PYCACHE_DIR_PATH}/*)
foreach(subdir ${SUBDIRS})
replace_py_with_pyc(${subdir})
endforeach()
message("--- Done copying .pyc files.")
endfunction()
replace_py_with_pyc(${Slicer_INSTALL_QTSCRIPTEDMODULES_LIB_DIR})
Can anyone give me a documentation or a guide to help me generate *.pyc and remove *.py of my module? I tried to simply substitute the files, using *.pyc and *.cpython-39.pyc, but it didn’t worked.