-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathsetup.py
executable file
·114 lines (102 loc) · 3.55 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
"""
Setup script that builds graphium_cpp.
It requires that a conda environment be created according to the
env.yml file. This file contains the build dependencies which
are necessary to compile and build graphium_cpp for use by the
graphium package.
"""
import platform
import sys
from distutils.core import setup
from pybind11.setup_helpers import Pybind11Extension, build_ext
import torch, rdkit, os
import numpy
# Constants
PYTHON_310 = "310"
# Base variables required for compilation
python_version = str(sys.version_info[0]) + str(sys.version_info[1])
path_separator = "/"
lib_folder_name = "lib"
boost_include = "include/boost"
package_compile_args = []
# Updating variables used during compilation based on OS
system = platform.system()
if system == "Darwin" or system == "Linux":
package_compile_args += ["-O3", "-Wall", "-Wmaybe-uninitialized", "-Wuninitialized"]
if system == "Darwin":
package_compile_args += ["-mmacosx-version-min=10.15"]
elif system == "Windows":
path_separator = "\\"
package_compile_args += [
"/DWIN32",
"/DRDKIT_DYN_LINK",
]
if python_version == PYTHON_310:
lib_folder_name = "lib"
else:
lib_folder_name = "Lib"
# Extracting paths to torch and rdkit dependencies
torch_dir = torch.__path__[0]
rdkit_lib_index = rdkit.__path__[0].split(path_separator).index(lib_folder_name) # breaks on windows
rdkit_prefix = "/".join(rdkit.__path__[0].split(path_separator)[:rdkit_lib_index])
# Windows-specific changed to rdkit path
if system == "Windows":
rdkit_prefix += "/Library"
boost_include = "include"
ext_modules = [
Pybind11Extension(
"graphium_cpp",
sources=[
"./graphium/graphium_cpp/graphium_cpp.cpp",
"./graphium/graphium_cpp/features.cpp",
"./graphium/graphium_cpp/labels.cpp",
"./graphium/graphium_cpp/commute.cpp",
"./graphium/graphium_cpp/electrostatic.cpp",
"./graphium/graphium_cpp/float_features.cpp",
"./graphium/graphium_cpp/graphormer.cpp",
"./graphium/graphium_cpp/one_hot.cpp",
"./graphium/graphium_cpp/random_walk.cpp",
"./graphium/graphium_cpp/spectral.cpp",
],
language="c++",
cxx_std=20,
include_dirs=[
os.path.join(torch_dir, "include"),
os.path.join(torch_dir, "include/torch/csrc/api/include"),
os.path.join(rdkit_prefix, "include/rdkit"),
os.path.join(rdkit_prefix, boost_include),
numpy.get_include(),
],
libraries=[
"RDKitAlignment",
"RDKitDataStructs",
"RDKitDistGeometry",
"RDKitDistGeomHelpers",
"RDKitEigenSolvers",
"RDKitForceField",
"RDKitForceFieldHelpers",
"RDKitGenericGroups",
"RDKitGraphMol",
"RDKitInchi",
"RDKitRDInchiLib",
"RDKitRDBoost",
"RDKitRDGeneral",
"RDKitRDGeometryLib",
"RDKitRingDecomposerLib",
"RDKitSmilesParse",
"RDKitSubstructMatch",
"torch_cpu",
"torch_python",
"c10",
f"boost_python{python_version}",
],
library_dirs=[os.path.join(rdkit_prefix, "lib"), os.path.join(torch_dir, "lib")],
extra_compile_args=package_compile_args,
)
]
setup(
ext_modules=ext_modules,
cmdclass={"build_ext": build_ext},
)