Looking up path to stdlib for locally active toolchain on Linux

On Ubuntu from a program (specifically Python script) executed in a given directory with an active Rust toolchain I want to lookup the path to libstd-<hash>.so of the active toolchain. In the given directory there resides a rust-toolchain file which contains a toolchain definition.

When the Python script is executed with rustup run <name of toolchain>, the environment variables are set and I should be able to lookup the corresponding libstd with the help of RUSTUP_HOME and RUSTUP_TOOLCHAIN from within the Python script.

However, if the active toolchain is not defined by a preceding rustup run, but by rust-toolchain or by rustup override set etc. (following the precedence rules), there are no environment variables set for the active toolchain which I could use from within the Python script. How can I lookup look up the path to the corresponding libstd (from within the Python script) in this case? Is there something like rustup run active ... to let rustup configure the environment for the active toolchain in the current directory?

Maybe rustc --print sysroot is enough for you?