Given this file structure, how can I read the cont...
# general
Given this file structure, how can I read the contents of the setup.cfg file in a plugin, given that I have the
of the BUILD file? I've tried using
await Get(DigestContents, ...)
targeting a PathGlob to that file path, but it causes infinite errors complaining about the file system changing 🤔
Offhand it sounds like that should work. I've seen that infinite filesystem changing loop, and we figured out the cause but of course now I can't remember what it was. @hundreds-father-404 you probably remember?
Hello! Hm, what are the errors? Indeed it should be await Get(DigestContents, PathGlobs(["path/to/"]) inside an async @rule
I don't remember that Benjy, hm. Do you remember any of the context for when that happened?
This doesn't work:
Copy code
from pants.backend.python.goals.setup_py import SetupKwargs, SetupKwargsRequest
from pants.engine.fs import DigestContents, GlobMatchErrorBehavior, PathGlobs
from pants.engine.rules import Get, collect_rules, rule
from import Target
from pants.engine.unions import UnionRule

class DeclarativeSetupKwargsRequest(SetupKwargsRequest):
    def is_applicable(cls, _: Target) -> bool:
        return True

def rules():
    return [
        UnionRule(SetupKwargsRequest, DeclarativeSetupKwargsRequest),

async def setup_kwargs_plugin(request: DeclarativeSetupKwargsRequest) -> SetupKwargs:
    digest_contents = await Get(
            description_of_origin="python declarative setup plugin",
    declarative_setup_contents = digest_contents[0].content.decode()
    return SetupKwargs({**request.explicit_kwargs},
You get this error:
Copy code
(vims-next) C02F9412MD6R-ML:vims-next taylocj1$ ./pants package backend/base
19:52:14.66 [ERROR] panic at 'called `Result::unwrap()` on an `Err` value: "Could not get field `value`: PyErr { ptype: <class \'AttributeError\'>, pvalue: Some(AttributeError(\'value\')), ptraceback: Some(<traceback object at 0x10e710380>) }"', src/externs/
19:52:14.66 [ERROR] Please set RUST_BACKTRACE=1, re-run, and then file a bug at <>.
19:52:14.66 [INFO] Filesystem changed during run: retrying `@rule(pants.backend.python.goals.setup_py.package_python_dist)` in 500ms...
repeatedly, over and over, until you manually kill the build
Oh, and the suggested action doesn't help. Setting RUST_BACKTRACE=1 doesn't seem to change anything in the output
Ah ha.
should be
. Sorry that's an atrocious error message, that's from the Rust FFI boundary
🤦 Ooof. Sorry about that, missed a tiny bit of the example in the docs, but yep, that's exactly it - works perfectly now. Thanks 😄
No need to apologize - the error should have been more helpful. I'll open an issue