Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use base executable when possible in PEP 517 build #2094

Merged
merged 1 commit into from
Jun 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions maturin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ def get_maturin_pep517_args(config_settings: Optional[Mapping[str, Any]] = None)
return args


def _get_sys_executable() -> str:
# Use the base interpreter path when running inside a venv to avoid recompilation
# when switching between venvs
executable = getattr(sys, "_base_executable", sys.executable)
if not os.path.exists(executable):
executable = sys.executable
return executable


def _additional_pep517_args() -> List[str]:
# Support building for 32-bit Python on x64 Windows
if platform.system().lower() == "windows" and platform.machine().lower() == "amd64":
Expand All @@ -68,7 +77,7 @@ def _build_wheel(
"pep517",
"build-wheel",
"-i",
sys.executable,
_get_sys_executable(),
]
options = _additional_pep517_args()
if editable:
Expand Down Expand Up @@ -180,7 +189,7 @@ def prepare_metadata_for_build_wheel(
# PEP 517 specifies that only `sys.executable` points to the correct
# python interpreter
"--interpreter",
sys.executable,
_get_sys_executable(),
]
command.extend(_additional_pep517_args())
pep517_args = get_maturin_pep517_args(config_settings)
Expand Down
Loading