forked from ContinuumIO/PostgresAdapter
-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
executable file
·90 lines (70 loc) · 2.61 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
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 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('./postgresadapter/core/PostgresAdapter*.so')
for file in files:
try:
os.remove(file)
except OSError:
pass
def setup_postgres(include_dirs, lib_dirs):
src = ['postgresadapter/core/PostgresAdapter.pyx',
'postgresadapter/core/postgres_adapter.c',
'postgresadapter/core/postgis_fields.c',
'postgresadapter/lib/converter_functions.c',
'postgresadapter/lib/kstring.c']
libraries = []
if sys.platform == 'win32':
libraries = ['libpq', 'ws2_32', 'secur32', 'shell32', 'advapi32']
else:
libraries = ['pq']
return Extension('postgresadapter.core.PostgresAdapter',
src,
include_dirs=include_dirs,
libraries=libraries,
library_dirs=lib_dirs)
def run_setup():
include_dirs = [os.path.join('postgresadapter', '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 = ['postgresadapter', 'postgresadapter.lib', 'postgresadapter.tests']
ext_modules.append(setup_postgres(include_dirs, lib_dirs))
packages.append('postgresadapter.core')
versioneer.versionfile_source = 'postgresadapter/_version.py'
versioneer.versionfile_build = 'postgresadapter/_version.py'
versioneer.tag_prefix = ''
versioneer.parentdir_prefix = 'postgresadapter-'
cmdclass = versioneer.get_cmdclass()
cmdclass['build_ext'] = build_ext
cmdclass['cleanall'] = CleanInplace
setup(name='postgresadapter',
version = versioneer.get_version(),
description='optimized IO for NumPy/Blaze',
author='Continuum Analytics',
author_email='support@continuum.io',
ext_modules=ext_modules,
packages=packages,
cmdclass=cmdclass)
if __name__ == '__main__':
run_setup()