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" ] ) ] )