Skip to content

[CMake] Rework fix for rebuild problems with python bytecode. - #23433

Open
hageboeck wants to merge 1 commit into
root-project:masterfrom
hageboeck:pycompile
Open

hageboeck wants to merge 1 commit into
root-project:masterfrom
hageboeck:pycompile

Conversation

@hageboeck

Copy link
Copy Markdown
Member

Due to the usage of copy_if_different, python source files might not have been updated before compiling them into bytecode. This could trigger rebuilds.

@guitargeek, I think I found a way to do the same fix but with less files that are stat-ed and checked:
Since a stamp file is already used for the compile step, the technique can be extended to a stamp file also for the copy step. This reduces the number of files that need to be checked by the CMake generators and ensures that the compile step always runs when any of the original source files changes.
With this technique, one could even go back to using copy_if_different, but the dependency tracking will work independent of which copy method is used.

The dependencies are now as follows:
<all source files> -> copy.stamp -> pybytecode.stamp

Due to the usage of copy_if_different, python source files might not
have been updated before compiling them into bytecode. Since a stamp
file is already used for the compile step, the technique can be extended
to a stamp file also for the copy step.  This reduces the number of
files that need to be checked by the CMake generators and ensures that
the compile step always runs when any of the original source files
changes.
With this technique, one could even go back to using copy_if_different,
but the dependency tracking will work independent of which copy method
is used.

The dependencies are now as follows:
<all source files> -> copy.stamp -> pybytecode.stamp
@hageboeck hageboeck self-assigned this Sep 21, 2026
@hageboeck
hageboeck requested a review from bellenot as a code owner September 21, 2026 08:03

@guitargeek guitargeek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice idea! This is indeed a cleaner dependency chain. These stamp files are the silver bullet 🙂

@github-actions

Copy link
Copy Markdown

Test Results

    21 files      21 suites   2d 23h 16m 5s ⏱️
 3 875 tests  3 871 ✅ 0 💤 4 ❌
72 514 runs  72 506 ✅ 0 💤 8 ❌

For more details on these failures, see this check.

Results for commit c11785b.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants