@@ -610,9 +610,13 @@ def _replace_vendor_with_unknown(target: str) -> Optional[str]:
610
610
def _prepare_build_environment () -> Dict [str , str ]:
611
611
"""Prepares environment variables to use when executing cargo build."""
612
612
613
+ executable = getattr (sys , "_base_executable" , sys .executable )
614
+ if not os .path .exists (executable ):
615
+ executable = sys .executable
616
+
613
617
# Make sure that if pythonXX-sys is used, it builds against the current
614
618
# executing python interpreter.
615
- bindir = os .path .dirname (sys . executable )
619
+ bindir = os .path .dirname (executable )
616
620
617
621
env = os .environ .copy ()
618
622
env .update (
@@ -622,9 +626,9 @@ def _prepare_build_environment() -> Dict[str, str]:
622
626
# interpreter from the path.
623
627
"PATH" : os .path .join (bindir , os .environ .get ("PATH" , "" )),
624
628
"PYTHON_SYS_EXECUTABLE" : os .environ .get (
625
- "PYTHON_SYS_EXECUTABLE" , sys . executable
629
+ "PYTHON_SYS_EXECUTABLE" , executable
626
630
),
627
- "PYO3_PYTHON" : os .environ .get ("PYO3_PYTHON" , sys . executable ),
631
+ "PYO3_PYTHON" : os .environ .get ("PYO3_PYTHON" , executable ),
628
632
}
629
633
)
630
634
return env
0 commit comments