-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsetup.py
executable file
·82 lines (70 loc) · 2.1 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
#!/usr/bin/env python3
import setuptools
import sys
import os
from glob import glob
from distutils.command.build_clib import build_clib
from distutils.core import setup
from distutils.extension import Extension
CYTHON_MODULES = glob('zydis/*.pyx')
if not os.path.exists('zydis-c/LICENSE'):
print(
"Err: Zydis C sources not found. Please make sure to clone this "
"repo recursively. This can now be fixed by executing:\n"
"\tgit submodule update --init --remote --recursive",
file=sys.stderr,
)
ZYDIS_INCLUDE_DIRS = [
'./zydis-c/include',
'./zydis-c/src',
'./zydis-c/dependencies/zycore/include',
'./zydis-c/dependencies/zycore/src',
'./cfgheaders',
]
ZYDIS_C = ('zydis', {
'include_dirs': ZYDIS_INCLUDE_DIRS,
'sources': glob('zydis-c/src/*.c') + glob('zydis-c/dependencies/src/*.c'),
})
try:
from Cython.Build import cythonize
def maybe_cythonize(ext):
cythonize(
ext,
aliases={'ZYDIS_INCLUDES': ZYDIS_INCLUDE_DIRS},
# build_dir='build',
language_level=3,
)
except ImportError:
print("Warn: Cython not found, using cached C sources.", file=sys.stderr)
if not os.path.exists("zydis/zydis.c"):
print(
"Err: No cached sources present. "
"Please install Cython (e.g. via pip).",
file=sys.stderr,
)
exit(1)
def maybe_cythonize(_):
pass
for module in CYTHON_MODULES:
maybe_cythonize(module)
setup(
name='zydis-py',
version='3.2.1',
packages=['zydis'],
libraries=[ZYDIS_C],
# install_requires=['Cython<=0.30'],
url='https://zydis.re',
license='MIT',
author='Joel Höner',
author_email='[email protected]',
description='Python bindings for the fast & lightweight Zydis disassembler',
cmdclass={'build_clib': build_clib},
ext_modules=[
Extension(
name=mod.split('.')[0].replace('/', '.').replace('\\', '.'),
sources=[mod.split('.')[0] + '.c'],
include_dirs=ZYDIS_INCLUDE_DIRS,
)
for mod in CYTHON_MODULES
],
)