bazel-contrib / bazel-contrib/rules_python

Add an option to opt-out of PYTHONSAFEPATH

Abierto
#2,060 13 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Starlark
Estrellas
688
Forks
721
Merge medio
15 h 7 min
PR fusionados (30 d)
76

Descripción

# 🚀 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": ""
}
)
```

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Comienza en la regla py_binary y sigue dónde se establece PYTHONSAFEPATH y cómo se aplica el argumento env de la regla. Reproduce el problema de herencia mediante el caso de uso de Meson de rules_foreign_cc y, después, verifica que la nueva opción preserve el valor predeterminado y permita omitir o deshabilitar PYTHONSAFEPATH.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
python
Área
build-system
Tipo de issue
Nueva funcionalidad
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
45/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.