bazel-contrib / bazel-contrib/rules_python

Add an option to opt-out of PYTHONSAFEPATH

オープン
#2,060 コメント 13 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Starlark
スター
688
フォーク
721
平均マージ
15時間 7分
マージ済み PR(30日)
76

説明

# 🚀 feature request

### Relevant Rules
`py_binary`

### Description
`py_binary` sets `PYTHONSAFEPATH=1` which while being a sensible default does cause problems. Most notably, in `rules_foreign_cc` where `py_binary` is used to wrap up the Meson build system (written in Python). While this is not an issue for the build system itself, it is an issue when Meson runs compilers or build scripts that are written in Python. The issue here is that Meson is starting processes which inherit Meson's environment variables including `PYTHONSAFEPATH`. This often breaks scripts which rely on importing modules from the directory in which they are contained.

### Describe the solution you'd like
I would like an option on `py_binary` that allows me to opt out of `PYTHONSAFEPATH`.
```starlark
py_binary(
name = "mypybinary",
safe_path = False, # defaults to True
)
```

### Describe alternatives you've considered
- Using `--action_env=PYTHONSAFEPATH=`: no effect
- Specifying the `env` argument on `py_binary` as follows: no effect

```starlark
py_binary(
name = "mypybinary",
env = {
"PYTHONSAFEPATH": ""
}
)
```

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

py_binary ルールから始めて、PYTHONSAFEPATH がどこで設定され、ルールの env 引数がどのように適用されるかを追跡します。rules_foreign_cc の Meson ユースケースを通じて継承の問題を再現し、その後、新しいオプションがデフォルトを維持しつつ、PYTHONSAFEPATH を省略または無効化できることを検証します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
build-system
issue の種類
機能追加
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。