-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsetup.py
101 lines (82 loc) · 3.03 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
"""
Adapted from python-udunits: https://code.google.com/p/python-udunits/
Copyright (C) 2011 Constantine Khroulev
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/>.
===
Author: Christopher Mueller
Copyright (C) UC Regents 2012
"""
try:
from setuptools import setup, Extension
from setuptools.command.bdist_egg import bdist_egg
except:
from distutils.core import setup, Extension
from distutils.command.build import build as build_
import os
# Custom build ordering ensuring that build_ext occurs BEFORE build_py - otherwise, the swig compiled udunits2_c.py is not included
class ext_build(build_):
sub_commands = [('build_ext', build_.has_ext_modules)] + build_.sub_commands
class egg_install(bdist_egg):
def run(self):
self.run_command('build_ext')
bdist_egg.run(self)
include_dirs = [
'/usr/include',
'/usr/local/include',
'/usr/include/udunits2',
]
if 'C_INCLUDE_PATH' in os.environ:
include_dirs = os.environ['C_INCLUDE_PATH'].split(':') + include_dirs
lib_dirs = [
'/lib',
'/usr/lib',
'/usr/local/lib',
]
if 'LD_LIBRARY_PATH' in os.environ:
lib_dirs = os.environ['LD_LIBRARY_PATH'].split(':') + lib_dirs
cmdclass = {'build': ext_build, 'bdist_egg':egg_install}
udunits_module = Extension('_udunits2_c',
sources=['udunitspy/udunits2_c.i'],
swig_opts=['-c++'] + ['-I%s' % i for i in include_dirs],
include_dirs=include_dirs,
library_dirs=lib_dirs,
libraries=['udunits2','expat'])
xml_dir = 'etc/udunits'
xml_files = [os.path.join(xml_dir, f) for f in os.listdir(xml_dir)]
classifiers = ''' Intended Audience :: Science/Research
Intended Audience :: Developers
Intended Audience :: Education
Operating System :: OS Independent
Programming Language :: Python
Topic :: Scientific/Engineering
Topic :: Education
Topic :: Software Development :: Libraries :: Python Modules'''
setup(name='udunitspy',
version='0.0.6',
description='Python wrapper for UDUNITS2',
long_description=open('DESC.txt').read(),
license='LICENSE.txt',
author='Christopher Mueller',
author_email='cmueller@asascience.com',
url='https://github.com/blazetopher/udunitspy/',
cmdclass=cmdclass,
ext_modules = [udunits_module],
classifiers=classifiers.split('\n'),
packages=['udunitspy', 'udunitspy.test'],
use_2to3=True,
data_files=[('etc/udunits', xml_files),],
install_requires = [
'numexpr==2.1',
'pytest==2.3.2',
'pytest-cov==1.6',
],
)