forked from arose/simpletraj
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
140 lines (125 loc) · 4.75 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/usr/bin/env python
import sys
from setuptools import setup, Extension, find_packages
import os
import versioneer
from versioneer import get_cmdclass
sdist = get_cmdclass()['sdist']
build_py = get_cmdclass()['build_py']
here = os.path.dirname(os.path.abspath(__file__))
node_root = os.path.join(here, 'js')
is_repo = os.path.exists(os.path.join(here, '.git'))
CLASSIFIERS = [
"Development Status :: 4 - Beta",
"Intended Audience :: Science/Research",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)",
"Programming Language :: C",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 3",
"Topic :: Scientific/Engineering :: Bio-Informatics",
"Topic :: Scientific/Engineering :: Chemistry",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX",
"Operating System :: Unix",
"Operating System :: MacOS",
]
# from MDAnalysis setup.py (http://www.mdanalysis.org/)
class NumpyExtension(Extension, object):
"""Derived class to cleanly handle setup-time (numpy) dependencies.
"""
# The only setup-time numpy dependency comes when setting up its
# include dir.
# The actual numpy import and call can be delayed until after pip
# has figured it must install numpy.
# This is accomplished by passing the get_numpy_include function
# as one of the include_dirs. This derived Extension class takes
# care of calling it when needed.
def __init__(self, *args, **kwargs):
self._np_include_dirs = []
super(NumpyExtension, self).__init__(*args, **kwargs)
@property
def include_dirs(self):
if not self._np_include_dirs:
for item in self._np_include_dir_args:
try:
self._np_include_dirs.append(item()) # The numpy callable
except TypeError:
self._np_include_dirs.append(item)
return self._np_include_dirs
@include_dirs.setter
def include_dirs(self, val):
self._np_include_dir_args = val
# from MDAnalysis setup.py (http://www.mdanalysis.org/)
def get_numpy_include():
try:
# Obtain the numpy include directory. This logic works across numpy
# versions.
# setuptools forgets to unset numpy's setup flag and we get a crippled
# version of it unless we do it ourselves.
try:
import __builtin__ # py2
__builtin__.__NUMPY_SETUP__ = False
except:
import builtins # py3
builtins.__NUMPY_SETUP__ = False
import numpy as np
except ImportError as e:
print(e)
print('*** package "numpy" not found ***')
print('Simpletraj requires a version of NumPy, even for setup.')
print('Please get it from http://numpy.scipy.org/ or install it through '
'your package manager.')
sys.exit(-1)
try:
numpy_include = np.get_include()
except AttributeError:
numpy_include = np.get_numpy_include()
return numpy_include
# Needed for large-file seeking under 32bit systems (for xtc/trr indexing and access).
largefile_macros = [
( "_LARGEFILE_SOURCE", None ),
( "_LARGEFILE64_SOURCE", None ),
( "_FILE_OFFSET_BITS","64" )
]
if __name__ == '__main__':
setup(
name = "simpletraj",
author = "Alexander S. Rose",
author_email = "[email protected]",
description = "Lightweight coordinate-only trajectory reader based on code from GROMACS, MDAnalysis, VMD.",
version = versioneer.get_version(),
cmdclass = versioneer.get_cmdclass(),
classifiers = CLASSIFIERS,
license = "GPL2",
url = "https://github.com/arose/simpletraj",
zip_safe = False,
packages = find_packages(),
ext_modules = [
NumpyExtension(
"simpletraj/xdrfile._libxdrfile2",
sources = [
"simpletraj/xdrfile/libxdrfile2_wrap.c",
"simpletraj/xdrfile/xdrfile.c",
"simpletraj/xdrfile/xdrfile_trr.c",
"simpletraj/xdrfile/xdrfile_xtc.c"
],
include_dirs = [ get_numpy_include ],
define_macros = largefile_macros
),
NumpyExtension(
"simpletraj/dcd._dcdmodule",
sources = [
"simpletraj/dcd/dcd.c"
],
include_dirs = [ get_numpy_include, "simpletraj/dcd/include" ],
),
],
requires = [ "numpy" ],
setup_requires = [ "numpy" ],
install_requires = [ "numpy" ],
extras_require = {
"netcdf": [ "netCDF4" ]
}
)