-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathsetup.py
executable file
·95 lines (76 loc) · 2.83 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
83
84
85
86
87
88
89
90
91
92
93
94
95
import os
import sys
import glob
from distutils.core import setup, Command
from distutils.extension import Extension
from Cython.Distutils import build_ext
import numpy
import dbadapter.pyodbc_setup
import versioneer
class CleanInplace(Command):
user_options = []
def initialize_options(self):
self.cwd = None
def finalize_options(self):
self.cwd = os.getcwd()
def run(self):
files = glob.glob('./dbadapter/pyodbc.*.so')
for file in files:
try:
os.remove(file)
except OSError:
pass
def setup_odbc(include_dirs, lib_dirs):
src_path = os.path.join(os.path.dirname(__file__), 'dbadapter/pyodbc/src')
src = [os.path.abspath(os.path.join(src_path, f))
for f in os.listdir(src_path)
if f.endswith('.cpp') ]
if sys.platform == 'win32':
libraries = ['odbc32', 'advapi32']
elif sys.platform == 'darwin':
if os.environ.get('UNIXODBC_PATH', ''):
include_dirs.append(os.path.join(os.environ.get('UNIXODBC_PATH')))
include_dirs.append(os.path.join(os.environ.get('UNIXODBC_PATH'), 'include'))
lib_dirs.append(os.path.join(os.environ.get('UNIXODBC_PATH'), 'DriverManager', '.libs'))
libraries = ['odbc']
else:
libraries = ['odbc']
else:
libraries = ['odbc']
return Extension('dbadapter.pyodbc',
src,
include_dirs=include_dirs,
libraries=libraries,
library_dirs=lib_dirs)
def run_setup():
include_dirs = [os.path.join('dbadapter', 'lib'),
numpy.get_include()]
if sys.platform == 'win32':
include_dirs.append(os.path.join(sys.prefix, 'Library', 'include'))
else:
include_dirs.append(os.path.join(sys.prefix, 'include'))
lib_dirs = []
if sys.platform == 'win32':
lib_dirs.append(os.path.join(sys.prefix, 'Library', 'lib'))
else:
lib_dirs.append(os.path.join(sys.prefix, 'lib'))
ext_modules = []
packages = ['dbadapter', 'dbadapter.lib', 'dbadapter.tests']
ext_modules.append(setup_odbc(include_dirs, lib_dirs))
versioneer.versionfile_source = 'dbadapter/_version.py'
versioneer.versionfile_build = 'dbadapter/_version.py'
versioneer.tag_prefix = ''
versioneer.parentdir_prefix = 'dbadapter-'
cmdclass = versioneer.get_cmdclass()
cmdclass['build_ext'] = build_ext
cmdclass['cleanall'] = CleanInplace
setup(name='dbadapter',
version = versioneer.get_version(),
description='optimized IO for NumPy/Blaze',
author='Continuum Analytics',
author_email='noreply@continuum.io',
ext_modules=ext_modules,
packages=packages,
cmdclass=cmdclass)
if __name__ == '__main__':
run_setup()