Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pyc files in Meson mesonbuild repo causing rebuilds #1342

Open
jjmaestro opened this issue Dec 15, 2024 · 0 comments · May be fixed by #1343
Open

pyc files in Meson mesonbuild repo causing rebuilds #1342

jjmaestro opened this issue Dec 15, 2024 · 0 comments · May be fixed by #1343

Comments

@jjmaestro
Copy link
Contributor

When I was using the meson rule, I saw that on the second consecutive bazel build //example call, Bazel seemed to be rebuilding / doing something when I thought it should just straight return since nothing should have changed.

I tried to see what was going on using --explain= and --execution_log_json_file= flags and found out it was due to pyc appearing in Meson's mesonbuild repository.

Repro: https://github.com/jjmaestro/rfcc-meson-rebuilding

TL;DR I still don't know how this is happening, I tried updating rules_python to the latest version and using some py_binary flags that I thought would ensure the pyc files would appear "before" (precompiled) but nothing seemed to help.

I had also tried excluding the __pycache__ folders and didn't see any effect... until @rickeylev pointed me to a better example in rules_python!

https://github.com/bazelbuild/rules_python/blob/727ab43107fb0b2d528140f609b873670a5c6c26/python/private/python_repository.bzl#L187-L195

The "fix" seems to be as simple as adding exclude = ["**/__pycache__/*"] to the glob in the Meson repo that imports the downloaded Meson tgz, although I'd love to understand more of what's happening and why! 😅 (e.g. why the pyc files seem to be coming from python 3.11 when I've tried forcing 3.13, etc).

For more context, see Slack 🧵.

jjmaestro added a commit to jjmaestro/rules_foreign_cc that referenced this issue Dec 15, 2024
Fixes bazel-contrib#1342

It seems that pyc files appear in the Meson repo between the first and
second time a python toolchain is used and if these are not excluded,
the new pyc files invalidate dependent rules, forcing a rebuild.

For more context, see bazel-contrib#1342 and
https://bazelbuild.slack.com/archives/CA306CEV6/p1734196424601509
jjmaestro added a commit to jjmaestro/rules_foreign_cc that referenced this issue Dec 18, 2024
Fixes bazel-contrib#1342

It seems that pyc files appear in the Meson repo between the first and
second time a python toolchain is used and if these are not excluded,
the new pyc files invalidate dependent rules, forcing a rebuild.

For more context, see bazel-contrib#1342 and
https://bazelbuild.slack.com/archives/CA306CEV6/p1734196424601509
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 a pull request may close this issue.

1 participant