5
5
from pathlib import Path
6
6
from shutil import copytree , rmtree , ignore_patterns
7
7
from subprocess import call , check_call
8
- from sysconfig import get_paths
8
+ import sysconfig
9
9
from textwrap import dedent
10
10
11
11
from setuptools import Extension , find_packages , setup
12
12
from setuptools .command .build_ext import build_ext as build_ext_orig
13
13
14
14
# RDKit version to build (tag from github repository)
15
- rdkit_tag = "Release_2024_03_5 "
15
+ rdkit_tag = "Release_2024_03_6 "
16
16
17
17
with open ("README.md" , "r" , encoding = "utf-8" ) as fh :
18
18
long_description = fh .read ()
@@ -168,14 +168,28 @@ def replace_all(file, search_exp, replace_exp):
168
168
169
169
# Fix a bug in conan or rdkit: target name for numpy is boost::numpy{pyversion} with small 'b'
170
170
# and not Boost::numpy{pyversion}
171
- # Line 345 in 2024_03_04 in CMakeLists.txt
172
- # target_link_libraries(rdkit_py_base INTERFACE Boost::${Boost_Python_Lib} "Boost::numpy${PYTHON_VERSION_MAJOR }${PYTHON_VERSION_MINOR }")
171
+ # Line 312 in 2024_03_06 in CMakeLists.txt
172
+ # NEW: target_link_libraries(rdkit_py_base INTERFACE " Boost::python${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}" "Boost::numpy${Python3_VERSION_MAJOR }${Python3_VERSION_MINOR }")
173
173
replace_all (
174
174
"CMakeLists.txt" ,
175
- 'target_link_libraries(rdkit_py_base INTERFACE Boost::${Boost_Python_Lib} "Boost::numpy${PYTHON_VERSION_MAJOR }${PYTHON_VERSION_MINOR }")' ,
176
- 'target_link_libraries(rdkit_py_base INTERFACE Boost::${Boost_Python_Lib} "boost::numpy${PYTHON_VERSION_MAJOR }${PYTHON_VERSION_MINOR }")' ,
175
+ 'target_link_libraries(rdkit_py_base INTERFACE " Boost::python${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}" "Boost::numpy${Python3_VERSION_MAJOR }${Python3_VERSION_MINOR }")' ,
176
+ 'target_link_libraries(rdkit_py_base INTERFACE "boost::python${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}" "boost::numpy${Python3_VERSION_MAJOR }${Python3_VERSION_MINOR }")' ,
177
177
)
178
178
179
+ # on windows, cmake is not configured to detect the python*.lib dynamic library
180
+ #
181
+ # replace_all(
182
+ # "CMakeLists.txt",
183
+ # 'target_link_libraries(rdkit_py_base INTERFACE ${Python3_LIBRARIES} )',
184
+ # 'message("HERE")\n message(${Python3_LIBRARIES})\n target_link_libraries(rdkit_py_base INTERFACE ${Python3_LIBRARIES} )',
185
+ # )
186
+
187
+ # on windows; bug in 2024_03_6
188
+ replace_all (
189
+ "CMakeLists.txt" ,
190
+ 'target_link_libraries(rdkit_py_base INTERFACE ${Python3_LIBRARY} )' ,
191
+ 'target_link_libraries(rdkit_py_base INTERFACE ${Python3_LIBRARIES} )' ,
192
+ )
179
193
180
194
if "macosx" in os .environ ["CIBW_BUILD" ]:
181
195
# Replace Cairo with cairo because conan uses lower case target names
@@ -192,22 +206,28 @@ def replace_all(file, search_exp, replace_exp):
192
206
)
193
207
194
208
209
+
210
+ print ("---- Conf vars" , file = sys .stderr )
211
+ print (sysconfig .get_paths (), file = sys .stderr )
212
+ print (sysconfig .get_config_vars (), file = sys .stderr )
213
+ print ("---- Conf vars" , file = sys .stderr )
214
+
215
+
195
216
# Define CMake options
196
217
options = [
218
+ # f"-DCMAKE_FIND_DEBUG_MODE=ON", # Enable debug mode
197
219
f"-DCMAKE_TOOLCHAIN_FILE={ conan_toolchain_path / 'conan_toolchain.cmake' } " ,
198
220
# For the toolchain file this needs to be set
199
221
f"-DCMAKE_POLICY_DEFAULT_CMP0091=NEW" ,
200
222
# Boost_VERSION_STRING is set but Boost_LIB_VERSION is not set by conan.
201
223
# Boost_LIB_VERSION is required by RDKit => Set manually
202
224
f"-DBoost_LIB_VERSION={ boost_lib_version } " ,
203
- # Select correct python interpreter
204
- f"-DPYTHON_EXECUTABLE={ sys .executable } " ,
205
- f"-DPYTHON_INCLUDE_DIR={ get_paths ()['include' ]} " ,
225
+ # Select correct python 3 version
226
+ f"-DPython3_ROOT_DIR={ Path (sys .prefix )} " ,
206
227
# RDKit build flags
207
228
"-DRDK_BUILD_INCHI_SUPPORT=ON" ,
208
229
"-DRDK_BUILD_AVALON_SUPPORT=ON" ,
209
230
"-DRDK_BUILD_PYTHON_WRAPPERS=ON" ,
210
- "-DRDK_BOOST_PYTHON3_NAME=python" , # Overwrite this. This is the name of the interface in cmake defined by conan.
211
231
"-DRDK_BUILD_YAEHMOP_SUPPORT=ON" ,
212
232
"-DRDK_BUILD_XYZ2MOL_SUPPORT=ON" ,
213
233
"-DRDK_INSTALL_INTREE=OFF" ,
@@ -228,17 +248,17 @@ def replace_all(file, search_exp, replace_exp):
228
248
vcpkg_path = cwd
229
249
vcpkg_inc = vcpkg_path / "vcpkg_installed" / "x64-windows" / "include"
230
250
vcpkg_lib = vcpkg_path / "vcpkg_installed" / "x64-windows" / "lib"
251
+
231
252
if sys .platform == "win32" :
253
+ def to_win_path (pt : Path ):
254
+ return str (pt ).replace ("\\ " , "/" )
255
+
232
256
options += [
233
- "-Ax64" ,
234
257
# DRDK_INSTALL_STATIC_LIBS should be fixed in newer RDKit builds. Remove?
235
258
"-DRDK_INSTALL_STATIC_LIBS=OFF" ,
236
259
"-DRDK_INSTALL_DLLS_MSVC=ON" ,
237
260
]
238
261
239
- def to_win_path (pt : Path ):
240
- return str (pt ).replace ("\\ " , "/" )
241
-
242
262
# Link cairo and freetype
243
263
options += [
244
264
f"-DCAIRO_INCLUDE_DIR={ to_win_path (vcpkg_inc )} " ,
@@ -277,13 +297,19 @@ def to_win_path(pt: Path):
277
297
if "linux" in sys .platform :
278
298
# Use ninja for linux builds
279
299
cmds = [
280
- f"cmake -S . -B build -G Ninja { ' ' .join (options )} " ,
300
+ f"cmake -S . -B build -G Ninja --debug-find-pkg=Python3 { ' ' .join (options )} " ,
281
301
"cmake --build build --config Release" ,
282
302
"cmake --install build" ,
283
303
]
304
+ elif sys .platform == "win32" :
305
+ cmds = [
306
+ f"cmake -S . -B build --debug-find-pkg=Python3 { ' ' .join (options )} " ,
307
+ "cmake --build build --config Release -v" ,
308
+ "cmake --install build" ,
309
+ ]
284
310
else :
285
311
cmds = [
286
- f"cmake -S . -B build { ' ' .join (options )} " ,
312
+ f"cmake -S . -B build --debug-find-pkg=Python3 { ' ' .join (options )} " ,
287
313
"cmake --build build --config Release" ,
288
314
"cmake --install build" ,
289
315
]
0 commit comments