bazel-contrib / bazel-contrib/rules_python

`bazel run` should run in bazel env working directory

未关闭
#2,679 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
help wanted P4
主要语言
Starlark
星标
688
派生
721
平均合并
15 小时 7 分钟
30 天内合并 PR
76

描述

# 🚀 feature request

### Relevant Rules
This is meant to change the behavior of `py_binary`

### Description
Currently if you run a binary with `bazel run` then the working directory will be the sandboxed bazel directory. This behavior is inconsistent with other implementations, for example in `rules_go` it is set like this https://github.com/bazel-contrib/rules_go/blob/b60f4475e3d97431318da1a0a81752a8884e6994/go/tools/go_bin_runner/main.go#L250

### Describe the solution you'd like

`bazel run` should use the `BUILD_WORKING_DIRECTORY` environment variable to set the working directory.

### Describe alternatives you've considered

You can do this hack where you add `--run_under="cd $PWD &&"` to the command but it only works on POSIX systems and you basically have to know the trick to have the command do what you might expect

贡献指南

打开贡献指南

调研方向

Start at the py_binary implementation involved in bazel run and compare its behavior with the rules_go runner linked in the issue. Verify how BUILD_WORKING_DIRECTORY is exposed, then confirm that bazel run uses it as the working directory rather than the sandbox directory.

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
build-system
Issue 类型
功能
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。