-
Notifications
You must be signed in to change notification settings - Fork 4
/
setup.py
33 lines (25 loc) · 989 Bytes
/
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
# type:ignore
"""Setup custom build step."""
from setuptools import setup
from setuptools.command.build_py import build_py
class Build(build_py):
"""Custom build_py step."""
def run(self):
"""Use ctypelib2 to convert to python."""
from ctypeslib.codegen import clangparser, config
from ctypeslib.codegen.codegenerator import Generator
from ctypeslib.library import Library
parser = clangparser.Clang_Parser(())
parser.parse("pynfc/nfc.c")
items = parser.get_result()
conf = config.CodegenConfig()
conf.searched_dlls = (
Library("/usr/lib/x86_64-linux-gnu/libnfc.so", "nm"),
Library("/usr/lib/x86_64-linux-gnu/libfreefare.so", "nm"),
)
with open("pynfc/nfc.py", "w") as out:
gen = Generator(out, conf)
gen.generate_headers(parser)
gen.generate_code(items)
return build_py.run(self)
setup(cmdclass={"build_py": Build})