-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
69 lines (62 loc) · 2.64 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
import numpy as np
import torch
from glob import glob
from Cython.Build import cythonize
from pybind11.setup_helpers import Pybind11Extension
from setuptools import setup, find_packages, Extension
from torch.utils.cpp_extension import BuildExtension, CUDAExtension
extensions = [
Extension("binsim.utils.graph.myGraph",
sources=["lib/binsim/utils/graph/myGraph.pyx"]),
Extension("binsim.disassembly.backend.binaryninja.fast_utils",
sources=["lib/binsim/disassembly/backend/binaryninja/fast_utils.pyx"],
include_dirs=[np.get_include()]),
Extension("binsim.neural.lm.asm2vec.fast_utils",
sources=["lib/binsim/neural/lm/asm2vec/fast_utils.pyx"])
]
pybind11_extensions = [
Pybind11Extension("binsim.disassembly.backend.binaryninja.graph.datautils",
sources=["lib/binsim/disassembly/backend/binaryninja/graph/src/main.cpp"]+
glob("lib/binsim/disassembly/backend/binaryninja/graph/src/graph/*.cpp")+
glob("lib/binsim/disassembly/backend/binaryninja/graph/src/utils/*.cpp")),
Pybind11Extension("binsim.disassembly.backend.ida.graph.jTransSeq.util.IDAIns",
sources=["lib/binsim/disassembly/backend/ida/graph/jTransSeq/util/IDAIns.cpp"]),
]
if torch.cuda.is_available():
torch_extensions = [
CUDAExtension('binsim.neural.nn.layer.dagnn.dagrnn_ops', [
"lib/binsim/neural/nn/layer/dagnn/dagrnn_ops/daggru.cu",
"lib/binsim/neural/nn/layer/dagnn/dagrnn_ops/tree_lstm.cu",
"lib/binsim/neural/nn/layer/dagnn/dagrnn_ops/graph.cpp",
"lib/binsim/neural/nn/layer/dagnn/dagrnn_ops/main.cpp"
], extra_compile_args={'cxx': ['-O3'], 'nvcc': ['-O3']})
]
else:
torch_extensions = []
print("CUDA is not available, skip building CUDA extensions.")
package_data = {
"binsim.disassembly.backend.binaryninja.graph": ["data/mnem/*/*"],
"binsim.disassembly.backend.ida.graph.jTransSeq.util": ["data/tokenizer/*"],
"binsim.disassembly.backend.ida" : ["extra_scripts/*"]
}
setup(
name="binsim",
version="0.2.0",
description="A simple python package for binary code similarity detection.",
author="w3i1ong",
author_email="[email protected]",
packages=find_packages("lib"),
package_dir={"": "lib"},
keywords="Binary Analysis, Deep Learning",
ext_modules=cythonize(extensions) + pybind11_extensions + torch_extensions,
package_data= package_data,
install_requires=[
'torch',
],
cmdclass={
'build_ext': BuildExtension
},
python_requires='>=3.10',
)
if __name__ == '__main__':
pass