forked from Starlink/starlink-pyndf
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
75 lines (63 loc) · 3.03 KB
/
Copy pathsetup.py
File metadata and controls
75 lines (63 loc) · 3.03 KB
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
# Copyright 2009-2011 Tom Marsh
# Copyright 2011 Tim Jenness
# All Rights Reserved.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from distutils.core import setup, Extension
import sys, os, subprocess, numpy
""" Setup script for the ndf python extension"""
library_dirs = []
include_dirs = []
# need to direct to where includes and libraries are
# use starlink command ndf_link to generate library list. Need to strip off '-l' from each one
if 'STARLINK_DIR' in os.environ:
os.environ['PATH'] = os.path.join(os.environ['STARLINK_DIR'], 'bin') + ':' + os.environ['PATH']
libraries = subprocess.Popen(['ndf_link',''], shell=True, stdout=subprocess.PIPE, env=os.environ).communicate()[0].split()
libraries = [x[2:].decode('ascii') for x in libraries]
library_dirs.append(os.path.join(os.environ['STARLINK_DIR'], 'lib'))
include_dirs.append(os.path.join(os.environ['STARLINK_DIR'], 'include'))
else:
print("Environment variable STARLINK_DIR not defined!")
exit(1)
include_dirs.append(numpy.get_include())
ndf = Extension('starlink.ndf.api',
define_macros = [('MAJOR_VERSION', '0'),
('MINOR_VERSION', '2')],
undef_macros = ['USE_NUMARRAY'],
include_dirs = include_dirs,
library_dirs = library_dirs,
runtime_library_dirs = library_dirs,
libraries = libraries,
sources = [os.path.join('starlink', 'ndf', 'ndf.c')]
)
hds = Extension('starlink.hds.api',
define_macros = [('MAJOR_VERSION', '0'),
('MINOR_VERSION', '2')],
undef_macros = ['USE_NUMARRAY'],
include_dirs = include_dirs,
library_dirs = library_dirs,
runtime_library_dirs = library_dirs,
libraries = libraries,
sources = [os.path.join('starlink', 'hds','hds.c')]
)
setup(name='starlink-pyndf',
version='0.2',
packages =['starlink','starlink.ndf','starlink.hds'],
ext_modules=[ndf,hds],
# metadata
author='Tom Marsh',
author_email='t.r.marsh@warwick.ac.uk',
description='Python interface to Starlink ndf libraries',
url='http://www.astro.warwick.ac.uk/',
license="GNU GPL v3",
)