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

Fix ninja error while python>=3.9 #48867

Merged
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
38 changes: 6 additions & 32 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import shutil
import subprocess
import sys
import sysconfig
from contextlib import contextmanager
from distutils.spawn import find_executable
from subprocess import CalledProcessError
Expand All @@ -43,34 +42,19 @@
print("export PY_VERSION = %s" % platform.python_version())
python_version = platform.python_version()
os.environ["PY_VERSION"] = python_version
else:
if os.getenv("PY_VERSION") != platform.python_version()[:3]:
raise RuntimeError(
"You set PY_VERSION=%s, but your current python environment is %s, you should keep them consistent!"
% (os.getenv("PY_VERSION"), platform.python_version()[:3])
)

# check cmake
CMAKE = find_executable('cmake3') or find_executable('cmake')
assert (
CMAKE
), 'The "cmake" executable is not found. Please check if Cmake is installed.'

# CMAKE: full path to python library
if platform.system() == "Windows":
cmake_python_library = "{}/libs/python{}.lib".format(
sysconfig.get_config_var("prefix"), sysconfig.get_config_var("VERSION")
)
# Fix virtualenv builds
if not os.path.exists(cmake_python_library):
cmake_python_library = "{}/libs/python{}.lib".format(
sys.base_prefix, sysconfig.get_config_var("VERSION")
)
else:
cmake_python_library = "{}/{}".format(
sysconfig.get_config_var("LIBDIR"),
sysconfig.get_config_var("INSTSONAME"),
)
if not os.path.exists(cmake_python_library):
libname = sysconfig.get_config_var("INSTSONAME")
libdir = sysconfig.get_config_var('LIBDIR') + (
sysconfig.get_config_var("multiarchsubdir") or ""
)
cmake_python_library = os.path.join(libdir, libname)

TOP_DIR = os.path.dirname(os.path.realpath(__file__))

Expand Down Expand Up @@ -642,16 +626,6 @@ def options_process(args, build_options):
for key, value in sorted(build_options.items()):
if value is not None:
args.append("-D{}={}".format(key, value))
if 'PYTHON_EXECUTABLE:FILEPATH' not in build_options.keys():
args.append("-D{}={}".format('PYTHON_EXECUTABLE', sys.executable))
if 'PYTHON_INCLUDE_DIR:PATH' not in build_options.keys():
args.append(
'-D{}={}'.format(
'PYTHON_INCLUDE_DIR', sysconfig.get_path("include")
)
)
if 'PYTHON_LIBRARY:FILEPATH' not in build_options.keys():
args.append('-D{}={}'.format('PYTHON_LIBRARY', cmake_python_library))


def get_cmake_generator():
Expand Down