Replies: 2 comments 1 reply
|
Took a look at your actual 1. 2. Bazel's default local cache is keyed to the output_base, which is not necessarily identical to the workspace path — so if anything in your install flow ever does end up invoking bazel against a different working directory (a temp copy, a different checkout, CI vs local), the default cache silently won't be shared even though your source is unchanged. The fix that's actually designed for this — a cache that's portable across different output_bases/workspace identities — is an explicit (Didn't run either of these myself — no easy way to verify against your actual C++ build graph — but both are grounded in what your setup.py is actually doing and in how those two Bazel caching mechanisms are documented to behave, so they should be quick to test.) |
|
Since both #1 and #2 landed and made zero difference (same ~7min twice in a row, disk_cache dir non-empty), that rules out "cache unreachable" — the actions themselves aren't cache-hitting, which means the action keys differ between runs, not that the cache can't be found. Most likely cause given your setup.py: To confirm: run |
Uh oh!
There was an error while loading. Please reload this page.
One of the promises of bazel is that it tends to make recompilations fast thanks to its ingenious caching system. While generally true, I find myself putting this statement to the test.
I have a project where I compile a CPP python extension using pybind11 (more specifically, I use the bazel specific extension). I can build my packages just fine. But, to make everything seamless to someone who does not care about bazel, I also wanted to ensure the package can be installed with a simple
pip install .. My efforts lead me to this setup.py + pyproject.toml combination. While a bit convoluted (I'm not sure if there is a better way of doing things) it gets the job done, with an annoying caveat: every time I make a change in the source code and I need to re-install the package, bazel appears to recompile everything from scratch (including the dependencies). If I use the standard rules_py rules from the repository (e.g.,bazel run //bindings:python .....), I get way faster results (only the changes are actually recompiled).My guess is that pip moves all files in a temporary folder and bazel does not recognize it already has cached the project. Since I'm not an expert, I would like to ask: is there a way of connecting the two caches? And are you aware of a better way to structure the installation scripts?
All reactions