bazel-contrib / bazel-contrib/rules_python

Expose `sysconfig` variables in `PyRuntimeInfo` provider

Open
#2,631 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Starlark
Stars
688
Forks
721
Avg merge
14h 49m
Merged PRs (30d)
81

Description

# 🚀 feature request

Downstream rules are potentially interested in the selected toolchains configuration.
Specifically, building C extension modules depends on things like `EXT_SUFFIX` to create proper extensions supporting the chosen interpreter.
Because that suffix ends up in file names, downstream rules may need that value at configure time, when they can't query the interpreter.
But the `@rules_python` `repository_rule` can easily determine these variables before configure time, for each registered toolchain.

This is related to:
- https://github.com/bazelbuild/rules_python/issues/824
- https://github.com/nicholasjng/nanobind-bazel/issues/61
- I'm sure other downstream bazel tooling related to C extensions would like this as-well

### Relevant Rules

This feature would ultimately need changes to:
- `PyRuntimeInfo` (basic schema)
- `py_runtime` (so that third party toolchains/interpreters can provide that information too)
- the internal pluming providing the `@rules_python` provided internal toolchains

### Description

`PyRuntimeInfo` needs a field `ext_suffix`, or alternatively `sysconfig_variables` (for future extension).
At extension instantiation time, when setting up the toolchain repos, the respective interpreters should be queried for their `ext_suffix`; alternatively, that information could be determined offline.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.