-
Notifications
You must be signed in to change notification settings - Fork 17
/
setup.py
executable file
·36 lines (27 loc) · 1.11 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
import os
import subprocess
from setuptools import setup, find_packages, Extension
# hum... borrowed from psycopg2
def get_pg_config(kind, pg_config="pg_config"):
p = subprocess.Popen([pg_config, '--%s' % kind], stdout=subprocess.PIPE)
r = p.communicate()
r = r[0].strip().decode('utf8')
if not r:
raise Warning(p[2].readline())
return r
include_dirs = [get_pg_config(d) for d in ("includedir", "pkgincludedir", "includedir-server")]
multicorn_utils_module = Extension('multicorn._utils',
include_dirs=include_dirs,
extra_compile_args=['-shared'],
sources=['src/utils.c'])
def get_version():
script_dir = os.path.dirname(os.path.realpath(__file__))
with open(os.path.join(script_dir, 'multicorn.control')) as f:
for line in f:
if line.startswith('default_version'):
return line.strip().split("'")[-2]
raise RuntimeError('default_version not found in multicorn.control')
setup(
version=get_version(),
ext_modules=[multicorn_utils_module]
)