Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

What environment variables are passed to each type of py_ rule? #2595

j2kun started this conversation in General
Discussion options

Version: 0.23.1 (9c6e26911a79fbf510a8f06d8eedb40f412023cf7fa6d1461def27116bff022c)

I noticed today that inside py_test the running test has access to RUNFILES_DIR as an environment variable, but a py_binary does not.

I could not find a reference as to what environment variables are given to each type of rule.


Side note: I also tried upgrading to 1.1.0 (bazel version 6.4.0), but the steps at https://rules-python.readthedocs.io/en/latest/getting-started.html#using-a-workspace-file failed with

Failed to load Starlark extension '@heir_pip_deps//:requirements.bzl'.
Cycle in the workspace file detected. This indicates that a repository is used prior to being defined.
The following chain of repository dependencies lead to the missing definition.
 - @heir_pip_deps
 - @python_3_11_host
This could either mean you have to add the '@python_3_11_host' repository with a statement like `http_archive` in your WORKSPACE file (note that transitive dependencies are not added automatically), or move an existing definition earlier in your WORKSPACE file.

I suspect there is a typo in the getting started instructions, but removing _host also doesn't seem to work. This is my minimal reproducing workspace: https://gist.github.com/j2kun/4047ee409e3f17599eb4b8389e94ead1

You must be logged in to vote

Replies: 1 comment

Comment options

https://bazel.build/reference/test-encyclopedia documents the various environment variables that bazel sets for every test; these are set outside the py rule process.

For the py rules, there's no environment variables that are promised to be set or not set. There's a few that happen to get set as part of bootstrapping, but we're trying to eliminate those.

HTH

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #2594 on January 30, 2025 00:27.

Morty Proxy This is a proxified and sanitized view of the page, visit original site.