54 target_dir = os.path.abspath(self.build_lib)
55 cmake_build_dir = os.getenv(
"PYCDE_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(
"\\",
"/")),
81 nanobind_dir = nanobind.cmake_dir()
82 cmake_args.append(
"-Dnanobind_DIR={}".format(
83 nanobind_dir.replace(
"\\",
"/")))
85 print(
"Skipping nanobind directory detection, nanobind not found.")
87 cxx = os.getenv(
"CXX")
89 cmake_args.append(
"-DCMAKE_CXX_COMPILER={}".format(cxx))
93 cmake_args.append(
"-DCMAKE_C_COMPILER={}".format(cc))
95 if "VCPKG_INSTALLATION_ROOT" in os.environ:
97 f
"-DCMAKE_TOOLCHAIN_FILE={os.environ['VCPKG_INSTALLATION_ROOT']}/scripts/buildsystems/vcpkg.cmake"
100 if "CIRCT_EXTRA_CMAKE_ARGS" in os.environ:
101 cmake_args += os.environ[
"CIRCT_EXTRA_CMAKE_ARGS"].split(
" ")
107 if platform.system() ==
"Linux":
108 python_libdir = sysconfig.get_config_var(
'LIBDIR')
109 python_library = sysconfig.get_config_var(
'LIBRARY')
110 if python_libdir
and not os.path.isabs(python_library):
111 python_library = os.path.join(python_libdir, python_library)
112 if python_library
and not os.path.exists(python_library):
113 print(
"Detected static linked python. Faking a library for cmake.")
114 fake_libdir = os.path.join(cmake_build_dir,
"fake_python",
"lib")
115 os.makedirs(fake_libdir, exist_ok=
True)
116 fake_library = os.path.join(fake_libdir,
117 sysconfig.get_config_var(
'LIBRARY'))
118 subprocess.check_call([
"ar",
"q", fake_library])
119 cmake_args.append(
"-DPython3_LIBRARY:PATH={}".format(fake_library))
122 subprocess.check_call([
"cmake", src_dir] + cmake_args, cwd=cmake_build_dir)
123 print(
" ".join([
"cmake", src_dir] + cmake_args))
126 subprocess.check_call([
137 if os.path.exists(target_dir):
138 shutil.rmtree(target_dir)
139 subprocess.check_call([
140 "cmake",
"--install",
".",
"--prefix",
141 os.path.join(target_dir,
"esiaccel"),
"--component",
"ESIRuntime"