changeset 52212:124c944b71b2 stable

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.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 13 Nov 2024 16:13:28 +0100
parents d57d1606049c
children 309f58964a9e
files setup.py
diffstat 1 files changed, 9 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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")