From 72b4b669a8173844b0536123db39342204bed0d0 Mon Sep 17 00:00:00 2001 From: Galaxy1458 <55453380+Galaxy1458@users.noreply.github.com> Date: Fri, 24 Nov 2023 11:03:14 +0800 Subject: [PATCH] Update setup.py (#59253) * Update setup.py * Update setup.py * Update setup.py --- setup.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index c64d694f35391..e0e52c27d5b63 100644 --- a/setup.py +++ b/setup.py @@ -47,16 +47,24 @@ f"you are using Python {python_version}" ) elif env_version is None: - print(f"export PY_VERSION = { python_version }") + print(f"Export PY_VERSION = { python_version }") os.environ["PY_VERSION"] = python_version elif env_version != version: warnings.warn( f"You set PY_VERSION={env_version}, but " f"your current python environment is {version} " - f"we will use your current python version to execute." + f"we will attempt to use the python version you set to execute." ) - os.environ["PY_VERSION"] = python_version + cmd = 'which python' + env_version + res = subprocess.run(cmd, shell = True, stdout=subprocess.PIPE) + if res.returncode == 0: + os.environ["PYTHON_EXECUTABLE"] = res + else: + raise RuntimeError( + "We can't find the version you set in your machine" + ) + # check cmake CMAKE = shutil.which('cmake3') or shutil.which('cmake')