|
19 | 19 |
|
20 | 20 | python_version = str(sys.version_info[0]) + str(sys.version_info[1]) |
21 | 21 |
|
22 | | -torch_dir = torch.__path__[0] |
23 | | -rdkit_lib_index = rdkit.__path__[0].split("/").index("lib") |
24 | | -rdkit_prefix = "/".join(rdkit.__path__[0].split("/")[:rdkit_lib_index]) |
| 22 | +# Base variables required for compilation |
| 23 | +path_separator = "/" |
| 24 | +lib_folder_name = "lib" |
| 25 | +boost_include = "include/boost" |
| 26 | +package_compile_args = [] |
25 | 27 |
|
| 28 | +# Updating variables used during compilation based on OS |
26 | 29 | system = platform.system() |
27 | | -package_compile_args = [ |
28 | | - "-O3", |
29 | | - "-Wall", |
30 | | - "-Wmissing-field-initializers", |
31 | | - "-Wmaybe-uninitialized", |
32 | | - "-Wuninitialized", |
33 | | -] |
| 30 | +if system == "Darwin" or system == "Linux": |
| 31 | + package_compile_args += ["-O3", "-Wall", "-Wmaybe-uninitialized", "-Wuninitialized"] |
| 32 | + |
34 | 33 | if system == "Darwin": |
35 | | - package_compile_args.append("-mmacosx-version-min=10.15") |
| 34 | + package_compile_args += ["-mmacosx-version-min=10.15"] |
36 | 35 | elif system == "Windows": |
37 | | - pass |
| 36 | + path_separator = "\\" |
| 37 | + lib_folder_name = "Lib" |
| 38 | + package_compile_args += ["/Wall", "/O3"] |
| 39 | + |
| 40 | +# Extracting paths to torch and rdkit dependencies |
| 41 | +torch_dir = torch.__path__[0] |
| 42 | +rdkit_lib_index = rdkit.__path__[0].split(path_separator).index(lib_folder_name) # breaks on windows |
| 43 | +rdkit_prefix = "/".join(rdkit.__path__[0].split(path_separator)[:rdkit_lib_index]) |
| 44 | + |
| 45 | +# Windows-specific changed to rdkit path |
| 46 | +if system == "Windows": |
| 47 | + rdkit_prefix += "/Library" |
| 48 | + boost_include = "include" |
38 | 49 |
|
39 | 50 | ext_modules = [ |
40 | 51 | Pybind11Extension( |
|
57 | 68 | os.path.join(torch_dir, "include"), |
58 | 69 | os.path.join(torch_dir, "include/torch/csrc/api/include"), |
59 | 70 | os.path.join(rdkit_prefix, "include/rdkit"), |
60 | | - os.path.join(rdkit_prefix, "include/boost"), |
| 71 | + os.path.join(rdkit_prefix, boost_include), |
61 | 72 | numpy.get_include(), |
62 | 73 | ], |
63 | 74 | libraries=[ |
| 75 | + "RDKitRDGeneral", |
64 | 76 | "RDKitAlignment", |
65 | 77 | "RDKitDataStructs", |
66 | 78 | "RDKitDistGeometry", |
|
73 | 85 | "RDKitInchi", |
74 | 86 | "RDKitRDInchiLib", |
75 | 87 | "RDKitRDBoost", |
76 | | - "RDKitRDGeneral", |
77 | 88 | "RDKitRDGeometryLib", |
78 | 89 | "RDKitRingDecomposerLib", |
79 | 90 | "RDKitSmilesParse", |
80 | 91 | "RDKitSubstructMatch", |
81 | 92 | "torch_cpu", |
82 | 93 | "torch_python", |
| 94 | + "c10", |
83 | 95 | f"boost_python{python_version}", |
84 | 96 | ], |
85 | 97 | library_dirs=[os.path.join(rdkit_prefix, "lib"), os.path.join(torch_dir, "lib")], |
|
0 commit comments