-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsetup.py
147 lines (137 loc) · 3.39 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
import os
import sys
import subprocess
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
from distutils.extension import Extension
from distutils.command.build_ext import build_ext
try:
from Cython.Build import cythonize
USE_CYTHON = True
except ImportError:
USE_CYTHON = False
WRAPPER_DIR = 'pycupid'
CUPID_DIR = 'cupid'
class custom_build_ext(build_ext):
def run(self):
# Build CUPID
subprocess.call(['make'])
# Then, build wrapper around it.
build_ext.run(self)
wrapper_sources = [
'pycupid',
]
cupid_sources = [
'cupidcfaddpixel.c',
'cupidcfdeleteps.c',
'cupidcferode.c',
'cupidcffreeps.c',
'cupidcfidl.c',
'cupidcflevels.c',
'cupidcfmakeps.c',
'cupidcfnebs.c',
'cupidcfscan.c',
'cupidcfxfer.c',
'cupidclumpfind.c',
'cupidconfigD.c',
'cupidconfigI.c',
'cupidconfigrms.c',
'cupiddefminpix.c',
'cupidfellwalker.c',
'cupidfwjoin.c',
'cupidfwmain.c',
'cupidfwpixelsets.c',
'cupidgaussclumps.c',
'cupidgccalcf.c',
'cupidgccalcg.c',
'cupidgcchisq.c',
'cupidgcdump.c',
'cupidgcfindmax.c',
'cupidgcfit.c',
'cupidgclistclump.c',
'cupidgcmodel.c',
'cupidgcndfclump.c',
'cupidgcprofwidth.c',
'cupidgcsetinit.c',
'cupidgcupdatearrays.c',
'cupidndfclump.c',
'cupidrca.c',
'cupidrca2.c',
'cupidrcheckface.c',
'cupidrcopyline.c',
'cupidredges.c',
'cupidreinhold.c',
'cupidrfill.c',
'cupidrfillclumps.c',
'cupidrfillline.c',
'cupidrinitedges.c',
'cupidsumclumps.c',
]
ext = '.pyx' if USE_CYTHON else '.c'
wrapper_sources = [os.path.join(WRAPPER_DIR, s + ext) for s in wrapper_sources]
cupid_sources = [os.path.join(CUPID_DIR, "src", s) for s in cupid_sources]
ext_sources = wrapper_sources + cupid_sources
extensions = [
Extension(
"pycupid.pycupid",
ext_sources,
include_dirs = [os.path.join(WRAPPER_DIR, "star", "include"),
os.path.join(CUPID_DIR, "include")],
library_dirs = [os.path.join(WRAPPER_DIR, "star", "lib")],
extra_link_args = ["-Wl,-rpath=" + os.path.join("$ORIGIN", "star", "lib")],
libraries = [
"ast",
"err_standalone",
"hds",
"ndf",
"pda",
# AST
"ast_pal",
"ast_grf_2.0",
"ast_grf_3.2",
"ast_grf_5.6",
"ast_grf3d",
"ast_pass2",
"ast_err",
"m",
# MERS
"chr",
"emsf",
"ems",
"cnf",
"starmem",
"pthread",
"starutil",
# HDS
"hdsf",
"hds",
# NDF
"psx",
"ary",
"prm",
"prm_a",
"ast_ems",
],
),
]
if USE_CYTHON:
extensions = cythonize(extensions)
setup(
name = 'pycupid',
version = '0.1.0',
author = u'Manuel Sánchez',
author_email = '[email protected]',
packages = ['pycupid'],
package_data = {'pycupid': ['star/lib/*',]},
url = 'https://github.com/msanchezc/pycupid',
description = 'Python wrappers for Starlink\'s CUPID package',
ext_modules = extensions,
cmdclass = {
'build_ext': custom_build_ext,
},
install_requires = {
'numpy >= 1.11.2',
}
)