Background: Support for discovering and loading scripted modules from .pyc
files has already been implemented for all scripted plugins and modules. You can find the related changes in the Slicer GitHub repository.
However, it’s crucial to note that, starting with Python 3.2, the default behavior of py_compile.compile, which is utilized in ctk_compile_python_scripts.cmake.in, is to generate files like __pycache__/scriptname.cpython-XY.pyc
, following the specifications in PEP-3147. This explains why we may not have *.pyc
files compiled after building the CompileSlicerPythonFiles
target.
Update: To address this, a pull request has been submitted to the CTK repository. This pull request, available at https://github.com/commontk/CTK/pull/1188, aims to ensure that Slicer scripts are consistently compiled as legacy .pyc
files.
After you have a chance to test and review, we will look into integrating the corresponding changes into Slicer.