-
Notifications
You must be signed in to change notification settings - Fork 12
/
setup.py
46 lines (41 loc) · 1.89 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
import sys, os, glob
import setuptools
from setuptools import setup, Extension
import subprocess
os.system('ln -f -h -s ../include cluster_toolkit/include')
sources = glob.glob(os.path.join('src','*.c'))
headers = glob.glob(os.path.join('include','*.h'))
try:
cflags = subprocess.check_output(['gsl-config', '--cflags'], universal_newlines=True).split()
lflags = subprocess.check_output(['gsl-config', '--libs'], universal_newlines=True).split()
except OSError:
raise Exception("Error: must have GSL installed and gsl-config working")
ext=Extension("cluster_toolkit._cluster_toolkit",
sources,
depends=headers,
include_dirs=['include'],
extra_compile_args=[os.path.expandvars(flag) for flag in cflags],
extra_link_args=[os.path.expandvars(flag) for flag in lflags])
dist = setup(name="cluster_toolkit",
author="Tom McClintock",
author_email="[email protected]",
description="Modules for modeling galaxy clusters and related systematics.",
license="MIT License",
url="https://github.com/tmcclintock/cluster_toolkit",
packages=['cluster_toolkit'],
package_data={'cluster_toolkit' : headers },
ext_modules=[ext],
install_requires=['cffi','numpy'],
setup_requires=['pytest_runner'],
tests_require=['pytest']
)
#setup.py doesn't put the .so file in the cluster_toolkit directory,
#so this bit makes it possible to
#import cluster_toolkit from the root directory.
#Not really advisable, but everyone does it at some
#point, so might as well facilitate it.
build_lib = glob.glob(os.path.join('build','*','cluster_toolkit','_cluster_toolkit*.so'))
if len(build_lib) >= 1:
lib = os.path.join('cluster_toolkit','_cluster_toolkit.so')
if os.path.lexists(lib): os.unlink(lib)
os.link(build_lib[0], lib)