forked from c3rb3ru5d3d53c/binlex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·71 lines (63 loc) · 2.14 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
#!/usr/bin/env python
import os
import re
import sys
from shutil import move
from glob import glob
import subprocess
import platform
from setuptools import Extension, setup
from setuptools.command.build_ext import build_ext
project_root = os.getenv('BUILD_DIR')
build_temp = os.path.join(os.getenv('BUILD_DIR'), 'build/')
__version__ = "1.1.1"
__author__ = "@c3rb3ru5d3d53c"
def get_base_prefix_compat():
return getattr(sys, "base_prefix", None) or getattr(sys, "real_prefix", None) or sys.prefix
def in_virtualenv():
return get_base_prefix_compat() != sys.prefix
class CMakeExtension(Extension):
def __init__(self, name, sources=[]):
super().__init__(name = name, sources = sources)
class CMakeBuild(build_ext):
def build_extension(self, ext):
extdir = os.path.abspath(os.path.dirname(self.get_ext_fullpath(ext.name)))
if not extdir.endswith(os.path.sep):
extdir += os.path.sep
cmake_args = [
f"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY={extdir}",
f"-DPYTHON_EXECUTABLE={sys.executable}",
"-DCMAKE_BUILD_TYPE=Release",
'-DBUILD_PYTHON_BINDINGS=true',
f'-DPYBIND11_PYTHON_VERSION={__version__}'
]
if not os.path.exists(build_temp):
os.makedirs(build_temp)
subprocess.check_call(
["cmake", project_root] + cmake_args, cwd=build_temp
)
subprocess.check_call(
["cmake", "--build", "."], cwd=build_temp
)
if platform.system() == 'Linux' and in_virtualenv() is False:
subprocess.check_call(
["make", "install"], cwd=build_temp
)
subprocess.check_call(
["ldconfig"], cwd=build_temp
)
setup(
name="pybinlex",
version=__version__,
author=__author__,
author_email="c3rb3ru5d3d53c@protonmail.com",
url="https://github.com/c3rb3ru5d3d53c/binlex",
long_description=open('README.md').read(),
long_description_content_type='text/markdown',
ext_modules=[CMakeExtension("pybinlex")],
cmdclass={
"build_ext": CMakeBuild
},
zip_safe=False,
python_requires=">=3.6",
)