This repository has been archived by the owner on Oct 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
79 lines (68 loc) · 2.51 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
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
import numpy
import os
# If the user set UDUNITS2_PREFIX, use it. Otherwise check some standard locations.
udunits2_include = ""
udunits2_lib = ""
try:
prefix = os.environ['UDUNITS2_PREFIX']
udunits2_include = prefix + "/include/"
udunits2_lib = prefix + "/lib/"
except:
print "Environment variable UDUNITS2_PREFIX not set. Trying known locations..."
prefixes = ["/usr/", "/usr/local/", "/opt/local/", "/sw/"]
for path in prefixes:
print "Checking '%s'..." % path
if path == "/opt/local/":
# Macports installs udunits2.h in /opt/local/include/udunits2/:
udunits2_include = path + "include/udunits2/"
else:
udunits2_include = path + "include/"
udunits2_lib = path + "lib/"
try:
os.stat(udunits2_include + "udunits2.h")
print """Found UDUNITS-2 in '%s':
include directory: %s
library directory: %s""" % (path, udunits2_include, udunits2_lib)
break
except:
pass
if udunits2_include == "" or udunits2_lib == "":
print "Could not find UDUNITS-2. Stopping..."
import sys
sys.exit(1)
libraries=['udunits2']
extra_compile_args=["-w"] # inhibit all warnings
# Define the extension
extension = Extension("udunits2",
sources=["udunits2.pyx"],
include_dirs=[numpy.get_include(), udunits2_include],
library_dirs=[udunits2_lib],
libraries=libraries,
extra_compile_args=extra_compile_args,
language="c")
setup(
name = "udunits2",
version = "0.1.0",
description = "Python UDUNITS-2 wrapper",
long_description = """
Python wrapper for the UNIDATA UDUNITS-2 library""",
author = "Constantine Khroulev",
author_email = "[email protected]",
url = "https://github.com/ckhroulev/py_udunits2",
classifiers=[
'Development Status :: 3 - Alpha',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: GNU General Public License (GPL)',
'Operating System :: MacOS :: MacOS X',
'Operating System :: POSIX',
'Programming Language :: Cython',
'Programming Language :: Python',
'Topic :: Scientific/Engineering',
'Topic :: Utilities'
],
cmdclass = {'build_ext': build_ext},
ext_modules = [extension]
)