-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
75 lines (62 loc) · 1.74 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
import glob
import os
from pathlib import Path
import platform
import shutil
from setuptools import setup, Extension, find_packages
from Cython.Build import cythonize
from Cython.Distutils import build_ext
# just a function to retrieve the readme data
def get_readme():
with open("README.md") as f:
return f.read()
# the source variable will have an extension appended to it dynamically
# that way, we can just decide to build using the generated c code or using the .pyx file with ease
source = "cytolk/tolk"
if "BUILD_CYTOLK" in os.environ:
source += ".pyx"
else:
source += ".c"
glob_files = glob.glob("tolk/src/*.cpp")
glob_files.extend(glob.glob("tolk/src/*.c"))
sources = [source]+glob_files
macros = [
('UNICODE', "1"),
('_WIN32', None),
('_EXPORTING', None),
]
extensions=[Extension(
"cytolk.tolk",
sources,
define_macros=macros,
language="C++",
libraries = "User32 Ole32 OleAut32".split(" "),
)]
print("copying DLLS")
libs = Path("tolk/libs") / ("x86" if "32" in platform.architecture()[0] else "x64")
for lib in libs.glob("*.dll"):
shutil.copy(str(lib), "cytolk")
print(f"copied {lib.name}")
setup(
name = "cytolk",
cmdclass = {"build_ext": build_ext},
version = "0.1.13",
description = "A cython wrapper over the tolk library",
long_description_content_type='text/markdown',
long_description = get_readme(),
ext_modules = cythonize(extensions),
packages = find_packages(),
package_data = {
"": ["*.dll"],
},
entry_points = {
"console_scripts": [
"cytolk = cytolk.main:cli"
]
}
)
dll_glob = glob.glob("cytolk/*.dll")
print("cleaning dlls")
for dll in dll_glob:
os.remove(dll)
print(f"{dll} removed")