-
Notifications
You must be signed in to change notification settings - Fork 4
/
setup.py
63 lines (54 loc) · 1.8 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
#!/usr/bin/env python3
# copied from https://stackoverflow.com/questions/4529555/building-a-ctypes-based-c-library-with-distutils
from setuptools import setup, Extension
from distutils.command.build_ext import build_ext as build_ext_orig
class CTypesExtension(Extension):
pass
class build_ext(build_ext_orig):
def build_extension(self, ext):
self._ctypes = isinstance(ext, CTypesExtension)
if self.compiler.compiler_type == "msvc":
for e in self.extensions:
e.extra_compile_args=["/std:c11"]
e.extra_link_args=["/DEF:pygfxd.def"]
return super().build_extension(ext)
def get_export_symbols(self, ext):
if self._ctypes:
return ext.export_symbols
return super().get_export_symbols(ext)
def get_ext_filename(self, ext_name):
if self._ctypes:
return ext_name + '.so'
return super().get_ext_filename(ext_name)
with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read()
setup(
name="pygfxd",
version="1.0.2",
author="Tharo",
description="Python bindings for libgfxd",
long_description=long_description,
long_description_content_type="text/markdown",
py_modules = ["pygfxd"],
ext_modules=[
CTypesExtension(
"libgfxd",
[
"libgfxd/gfxd.c",
"libgfxd/uc_f3d.c",
"libgfxd/uc_f3db.c",
"libgfxd/uc_f3dex.c",
"libgfxd/uc_f3dex2.c",
"libgfxd/uc_f3dexb.c",
"libgfxd/uc.c",
],
include_dirs=["libgfxd"],
extra_compile_args = [
"-std=c11",
"-Wall",
"-g",
],
),
],
cmdclass={'build_ext': build_ext},
)