[rfc] Allow repository rules to lazily declare environment variable deps#20787
[rfc] Allow repository rules to lazily declare environment variable deps#20787rbeasley wants to merge 1 commit intobazelbuild:masterfrom
Conversation
|
I reviewed the test failures, and they don't appear to be related to my changes. I don't think my change introduced thread/synchronization bugs, but I need to defer to the experts.
|
|
Thanks for the PR! I'll take a look in a minute. Anyhow the test failures are definitely unrelated; see #20790 |
This commit adds a new repository context method, `getenv`, which allows Starlark repository rule implementations to lazily declare environment variable dependencies. This is intended to allow repository rules to establish dependencies on environment variables whose names aren't known in advance. This is work towards bazelbuild#19511. Notes ===== - I don't speak Java, so expect funny smells and copypasta. - `rctx.getenv` behaves similarly to Python's `os.getenv`. - `rctx.getenv` is to environment variables what `rctx.path(Label)` is to files. Future work =========== - Implement bzlmod support.
04f5939 to
7202924
Compare
|
@bazel-io flag |
|
@bazel-io fork 7.1.0 |
…riable deps (#20944) This commit adds a new repository context method, `getenv`, which allows Starlark repository rule implementations to lazily declare environment variable dependencies. This is intended to allow repository rules to establish dependencies on environment variables whose names aren't known in advance. This is work towards #19511. Notes ===== - I don't speak Java, so expect funny smells and copypasta. - `rctx.getenv` behaves similarly to Python's `os.getenv`. - `rctx.getenv` is to environment variables what `rctx.path(Label)` is to files. Future work =========== - Implement bzlmod support. RELNOTES: Added a new method `repository_ctx.getenv`, which allows Starlark repository rules to declare environment variable dependencies during the fetch, instead of upfront using `repository_rule.environ`. Closes #20787. Commit c230e39 PiperOrigin-RevId: 599568358 Change-Id: I2c1948cd23643d28bf1d41e9baaf98a902112cc7 Co-authored-by: Ryan Beasley <beasleyr@vmware.com>
|
What happens if one downgrades the Bazel version in an existing output base from one that supports the |
@lberki Just to make sure I understand correctly, the With that, consider the following sequence of events:
If the user downgrades Bazel to an older version, they'll have to revert their repository rule definition (because Does that sound right? Am I missing anything? |
|
No, you are not missing anything -- I didn't realize in my (very literal) fever dream that resulted in the above comment that |
This commit adds a new repository context method,
getenv, which allows Starlark repository rule implementations to lazily declare environment variable dependencies. This is intended to allow repository rules to establish dependencies on environment variables whose names aren't known in advance.This is work towards #19511.
Notes
rctx.getenvbehaves similarly to Python'sos.getenv.rctx.getenvis to environment variables whatrctx.path(Label)is to files.Future work