The rust package in conda-forge uses
CARGO_BUILD_TARGET (https://doc.rust-lang.org/cargo/reference/environment-variables.html). I had to patch Mercurial's setup.py to use Rust for the conda-forge package (https://github.com/conda-forge/mercurial-feedstock/pull/59/files#diff-d7075654874cb08007a21aaab3ecd4b3453a9087e7505d034d548b8938b599bcR6).
I propose a change that would avoid this patch. I tried to have the smallest change possible to have the right path with and without
CARGO_BUILD_TARGET. Note that without
CARGO_BUILD_TARGET, this gives:
In : os.path.join( ...: 'rust', 'target', os.environ.get('CARGO_BUILD_TARGET', ''), 'release' ...: ) Out: 'rust/target/release'