-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.py
More file actions
117 lines (92 loc) · 3.79 KB
/
setup.py
File metadata and controls
117 lines (92 loc) · 3.79 KB
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# coding: utf-8
from setuptools import setup
from setuptools.extension import Extension
from Cython.Build import cythonize
import os
import sys
import shutil
import warnings
def is_windows():
return os.name == 'nt'
def check_win_binaries(*binaries):
for binary in binaries:
if not os.path.exists(binary):
warnings.warn("binary is missing in %s directory" % binary)
return False
return True
def move_binaries():
libxlsx_compiled_dir = os.path.join(_THIS_, "libs", "XLSX", "bin")
zlib_compiled_dir = os.path.join(_THIS_, "libs", "zlib", "bin")
zlib_compiled = os.path.join(zlib_compiled_dir, "zlib.dll")
libxlsx_compiled = os.path.join(libxlsx_compiled_dir, "xlsxwriter.dll")
if check_win_binaries(zlib_compiled, libxlsx_compiled):
shutil.copyfile(zlib_compiled, os.path.join(MODULE_PATH, "zlib.dll"))
shutil.copyfile(libxlsx_compiled, os.path.join(MODULE_PATH, "xlsxwriter.dll"))
else:
warnings.warn("Some sufficient binaries are missing, try to build them with build_c_libs.cmd")
def merge_dicts(*dicts):
result = {}
for dct in dicts:
result.update(dct)
return result
language_level = sys.version_info[0]
_THIS_ = os.path.dirname(os.path.realpath(__file__))
module_name = "impeller"
MODULE_PATH = os.path.join(_THIS_, module_name)
if is_windows():
libxlsx_include = os.path.join(_THIS_, "libs", "XLSX", "include")
libxlsx_lib = os.path.join(_THIS_, "libs", "XLSX", "lib")
move_binaries()
workbook = [os.path.join(MODULE_PATH, "c_workbook.pyx")]
worksheet = [os.path.join(MODULE_PATH, "c_worksheet.pyx")]
common = [os.path.join(MODULE_PATH, "c_common.pyx")]
formatting = [os.path.join(MODULE_PATH, "c_format.pyx")]
chart = [os.path.join(MODULE_PATH, "c_chart.pyx")]
common_extension_args = {
"libraries": ['xlsxwriter'],
"language": "c"
}
OS_specific_extension_args = {}
if is_windows():
OS_specific_extension_args = {
"include_dirs": [libxlsx_include],
"library_dirs": [libxlsx_lib],
}
# dlls for windows, linux have them in default location
package_data = {}
if is_windows():
# Instead of providing them in PATH - ship with the lib
package_data = {'impeller': ["zlib.dll", "xlsxwriter.dll"]}
extensions_args = {}
extensions_args.update(common_extension_args)
extensions_args.update(OS_specific_extension_args)
extensions_sources = [{"name": "impeller.c_workbook", "sources": workbook},
{"name": "impeller.c_worksheet", "sources": worksheet},
{"name": "impeller.c_format", "sources": formatting},
{"name": "impeller.c_common", "sources": common},
{"name": "impeller.c_chart", "sources": chart}]
extensions = [Extension(**merge_dicts(extensions_args, source)) for source in extensions_sources]
setup(
name="Impeller",
description='Thin Cython wrapper around modified fork of libxlsxwriter, '
'partially compatible with Python XlsxWriter. The purpose of the project is fast .xlsx writing.',
author='Dmitriy Emelianov',
author_email='emelianovds@yandex.ru',
url="https://github.com/m9psy/Impeller",
version='0.1.dev0',
packages=['impeller'],
package_data=package_data,
ext_modules=cythonize(extensions, compiler_directives={'language_level': language_level}),
classifiers=[
"License :: OSI Approved :: BSD License",
"Development Status :: 2 - Pre-Alpha",
"Intended Audience :: Developers",
"Operating System :: POSIX",
"Operating System :: Microsoft :: Windows",
"Programming Language :: C",
"Programming Language :: Cython",
"Programming Language :: Python",
"Topic :: Software Development :: Libraries",
"Topic :: Office/Business :: Financial :: Spreadsheet"
]
)