> ## Documentation Index
> Fetch the complete documentation index at: https://site.aspect.build/llms.txt
> Use this file to discover all available pages before exploring further.

# @aspect_rules_py//py:toolchains.bzl

> Bazel rules_py toolchain helpers including register_autodetecting_python_toolchain to autodetect a local Python interpreter compatible with rules_py.

<Callout icon="book">
  Documentation for [@aspect\_rules\_py@v1.8.4](https://registry.bazel.build/modules/aspect_rules_py/1.8.4) -- <Icon icon="github" iconType="brands" /> [View source](https://github.com/aspect-build/rules_py/blob/v1.8.4/py/toolchains.bzl)
</Callout>

Declare toolchains

## Function: `register_autodetecting_python_toolchain`

Registers a Python toolchain that will auto detect the location of Python that can be used with rules\_py.

The autodetecting Python toolchain replaces the automatically registered one under bazel, and correctly handles the
Python virtual environment indirection created by rules\_py. However it is recommended to instead use one of the prebuilt
Python interpreter toolchains from rules\_python, rather than rely on the correct Python binary being present on the host.

### Parameters

<ParamField body="name" type="name" required />

## Function: `rules_py_toolchains`

Create a downloaded toolchain for every tool under every supported platform.

### Parameters

<ParamField body="name" type="name" default={`rules_py_tools`}>
  prefix used in created repositories
</ParamField>

<ParamField body="register" type="name" default={`True`}>
  whether to call the register\_toolchains, should be True for WORKSPACE and False for bzlmod.
</ParamField>

<ParamField body="is_prerelease" type="name" default={`True`}>
  True iff there are no pre-built tool binaries for this version of rules\_py
</ParamField>
