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
|
from distutils.core import setup, Extension
from os.path import join
######################################################################
# NUMPY
try:
import numpy
except ImportError:
print "numpy must be installed to build pywcs."
print "ABORTING."
sys.exit(1)
try:
numpy_include = numpy.get_include()
except AttributeError:
numpy_include = numpy.get_numpy_include()
######################################################################
# PyFITS
try:
import pyfits
except ImportError:
print "WARNING: PyFITS must be installed to use pywcs."
print " Since this is not a build-time dependency, the build will proceed."
######################################################################
######################################################################
# WCSLIB
WCSVERSION = "4.3"
WCSLIB = "wcslib-%s" % WCSVERSION # Path to wcslib
WCSLIBC = join('pywcs', WCSLIB, "C") # Path to wcslib source files
WCSFILES = [ # List of wcslib files to compile
'flexed/wcsulex.c',
'flexed/wcsutrn.c',
'cel.c',
'lin.c',
'log.c',
'prj.c',
'spc.c',
'sph.c',
'spx.c',
'tab.c',
'wcs.c',
'wcsfix.c',
'wcshdr.c',
'wcspih.c',
'wcstrig.c',
'wcsunits.c',
'wcsutil.c']
WCSFILES = [join(WCSLIBC, x) for x in WCSFILES]
######################################################################
######################################################################
# GENERATE DOCSTRINGS IN C
docstrings = {}
execfile("pywcs/doc/docstrings.py", docstrings)
keys = docstrings.keys()
keys.sort()
fd = open("pywcs/src/docstrings.h", "w")
fd.write('/* This file is autogenerated by setup.py. To edit its contents\n')
fd.write(' edit doc/docstrings.py\n')
fd.write('*/\n')
for key in keys:
if key.startswith('__'):
continue
val = docstrings[key].lstrip().encode("string_escape").replace('"', '\\"')
fd.write("static const char doc_%s[] = \"%s\";\n\n" % (key, val))
fd.close()
######################################################################
setup(name="hstwcs",
version="0.1",
description="HST WCS Corrections",
packages=['hstwcs', 'hstwcs/pywcs', 'hstwcs/updatewcs', 'hstwcs/wcsutil', 'hstwcs/distortion'],
package_dir={'hstwcs':'lib', 'hstwcs/pywcs': 'pywcs/pywcs', 'hstwcs/updatewcs': 'updatewcs',
'hstwcs/wcsutil': 'wcsutil', 'hstwcs/distortion': 'distortion'},
ext_modules=[
Extension('hstwcs.pywcs._pywcs',
['pywcs/src/pywcs.c'] +
WCSFILES,
include_dirs=[
numpy_include,
WCSLIBC,
"src"
]
)
]
)
|