Technically, the .py files are not replaced, there are removed.
The target CompileSlicerPythonFiles depends on the CopySlicerPythonScriptFiles one, these are defined using the ctkFunctionAddCompilePythonScriptTargets CMake function.
See Slicer/CMakeLists.txt#L1280-L1309
To properly support “compiling” source file exclusively to .pyc, the CMake function ctkFunctionAddCompilePythonScriptTargets should be improved to accept an new parameter option (e.g SKIP_SCRIPT_COPY).
See CTK/CMake/ctkMacroCompilePythonScript.cmake
The ctkMacroCompilePythonScript.cmake CMake module could also be updated to define an option for controlling the behavior globally (e.g CTK_COMPILE_PYTHON_SCRIPT_SKIP_SCRIPT_COPY).
This new option should be added to SlicerConfig.cmake.in, that way extension build against Slicer would also leverage it.
This should provide you with enough hints to move forward and create a pull request at https://github.com/commontk/CTK
We will address corner cases during the review process.