54 target_dir = os.path.abspath(self.build_lib)
55 cmake_build_dir = os.getenv(
"CMAKE_BUILD_DIR")
56 if not cmake_build_dir:
57 cmake_build_dir = os.path.abspath(
58 os.path.join(target_dir,
"..",
"cmake_build"))
61 os.makedirs(cmake_build_dir, exist_ok=
True)
62 cmake_cache_file = os.path.join(cmake_build_dir,
"CMakeCache.txt")
63 if os.path.exists(cmake_cache_file):
64 os.remove(cmake_cache_file)
71 "-DCMAKE_BUILD_TYPE={}".format(cfg),
72 "-DPython3_EXECUTABLE={}".format(sys.executable.replace(
"\\",
"/")),
73 "-DPython_EXECUTABLE={}".format(sys.executable.replace(
"\\",
"/")),
83 nanobind_dir = nanobind.cmake_dir()
84 cmake_args.append(
"-Dnanobind_DIR={}".format(
85 nanobind_dir.replace(
"\\",
"/")))
87 print(
"Skipping nanobind directory detection, nanobind not found.")
89 cxx = os.getenv(
"CXX")
91 cmake_args.append(
"-DCMAKE_CXX_COMPILER={}".format(cxx))
95 cmake_args.append(
"-DCMAKE_C_COMPILER={}".format(cc))
97 if "VCPKG_INSTALLATION_ROOT" in os.environ:
99 f
"-DCMAKE_TOOLCHAIN_FILE={os.environ['VCPKG_INSTALLATION_ROOT']}/scripts/buildsystems/vcpkg.cmake"
102 if "CIRCT_EXTRA_CMAKE_ARGS" in os.environ:
103 cmake_args += os.environ[
"CIRCT_EXTRA_CMAKE_ARGS"].split(
" ")
109 if platform.system() ==
"Linux":
110 python_libdir = sysconfig.get_config_var(
'LIBDIR')
111 python_library = sysconfig.get_config_var(
'LIBRARY')
112 if python_libdir
and not os.path.isabs(python_library):
113 python_library = os.path.join(python_libdir, python_library)
114 if python_library
and not os.path.exists(python_library):
115 print(
"Detected static linked python. Faking a library for cmake.")
116 fake_libdir = os.path.join(cmake_build_dir,
"fake_python",
"lib")
117 os.makedirs(fake_libdir, exist_ok=
True)
118 fake_library = os.path.join(fake_libdir,
119 sysconfig.get_config_var(
'LIBRARY'))
120 subprocess.check_call([
"ar",
"q", fake_library])
121 cmake_args.append(
"-DPython3_LIBRARY:PATH={}".format(fake_library))
124 subprocess.check_call([
"cmake", src_dir] + cmake_args, cwd=cmake_build_dir)
125 print(
" ".join([
"cmake", src_dir] + cmake_args))
128 subprocess.check_call(
141 if os.path.exists(target_dir):
142 shutil.rmtree(target_dir)
143 subprocess.check_call(
149 os.path.join(target_dir,
"esiaccel"),