setup: make sure Rust build its extension for the right python
Strictly speaking, only "PYTHON_SYS_EXECUTABLE" seems to be necessary, but I
don't want to take a chances, as in testing "PYTHON" also had an effect.
--- a/setup.py Wed Nov 13 13:33:36 2024 +0100
+++ b/setup.py Wed Nov 13 16:13:28 2024 +0100
@@ -1566,6 +1566,15 @@
env['HOME'] = pwd.getpwuid(os.getuid()).pw_dir
+ # Wildy shooting in the dark to make sure rust-cpython use the right
+ # python
+ if not sys.executable:
+ msg = "Cannot determine which Python to compile Rust for"
+ raise RustCompilationError(msg)
+ env['PYTHON_SYS_EXECUTABLE'] = sys.executable
+ env['PYTHONEXECUTABLE'] = sys.executable
+ env['PYTHON'] = sys.executable
+
cargocmd = ['cargo', 'rustc', '--release']
rust_features = env.get("HG_RUST_FEATURES")