-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·182 lines (147 loc) · 5.42 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#!/usr/bin/env python
"""
This is the main setup script for h5py (http://www.h5py.org).
Most of the functionality is provided in two separate modules:
setup_configure, which manages compile-time/Cython-time build options
for h5py, and setup_build, which handles the actual compilation process.
"""
from setuptools import Extension, setup
from distutils.cmd import Command
import sys
import os
import os.path as op
# Newer packaging standards may recommend removing the current dir from the
# path, add it back if needed.
if '' not in sys.path:
sys.path.insert(0, '')
import setup_build, setup_configure
VERSION = '3.3.0'
# Minimum supported versions of Numpy & Cython depend on the Python version
NUMPY_MIN_VERSIONS = [
# Numpy Python
('1.14.5', "=='3.7'"),
('1.17.5', "=='3.8'"),
('1.19.3', ">='3.9'"),
]
# these are required to use h5py
RUN_REQUIRES = ["cached-property; python_version<'3.8'"] + [
f"numpy >={np_min}; python_version{py_condition}"
for np_min, py_condition in NUMPY_MIN_VERSIONS
]
# these are required to build h5py
# For packages we link to (numpy, mpi4py), we build against the oldest
# supported version; h5py wheels should then work with newer versions of these.
# Downstream packagers - e.g. Linux distros - can safely build with newer
# versions.
SETUP_REQUIRES = [
'pkgconfig',
"Cython >=0.29; python_version<'3.8'",
"Cython >=0.29.14; python_version=='3.8'",
"Cython >=0.29.15; python_version>='3.9'",
] + [
f"numpy =={np_min}; python_version{py_condition}"
for np_min, py_condition in NUMPY_MIN_VERSIONS
]
if setup_configure.mpi_enabled():
RUN_REQUIRES.append('mpi4py >=3.0.2')
SETUP_REQUIRES.append("mpi4py ==3.0.2; python_version<'3.8'")
SETUP_REQUIRES.append("mpi4py ==3.0.3; python_version>='3.8'")
# Set the environment variable H5PY_SETUP_REQUIRES=0 if we need to skip
# setup_requires for any reason.
if os.environ.get('H5PY_SETUP_REQUIRES', '1') == '0':
SETUP_REQUIRES = []
# --- Custom Distutils commands -----------------------------------------------
class test(Command):
"""
Custom Distutils command to run the h5py test suite.
This command will invoke build/build_ext if the project has not
already been built. It then patches in the build directory to
sys.path and runs the test suite directly.
"""
description = "Run the test suite"
user_options = [('detail', 'd', 'Display additional test information')]
def initialize_options(self):
self.detail = False
def finalize_options(self):
self.detail = bool(self.detail)
def run(self):
""" Called by Distutils when this command is run """
import sys
buildobj = self.distribution.get_command_obj('build')
buildobj.run()
oldpath = sys.path
oldcwd = os.getcwd()
build_lib_dir = op.abspath(buildobj.build_lib)
try:
sys.path = [build_lib_dir] + oldpath
os.chdir(build_lib_dir)
import h5py
sys.exit(h5py.run_tests())
finally:
sys.path = oldpath
os.chdir(oldcwd)
CMDCLASS = {'build_ext': setup_build.h5py_build_ext,
'test': test, }
# --- Distutils setup and metadata --------------------------------------------
cls_txt = \
"""
Development Status :: 5 - Production/Stable
Intended Audience :: Developers
Intended Audience :: Information Technology
Intended Audience :: Science/Research
License :: OSI Approved :: BSD License
Programming Language :: Cython
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: Implementation :: CPython
Topic :: Scientific/Engineering
Topic :: Database
Topic :: Software Development :: Libraries :: Python Modules
Operating System :: Unix
Operating System :: POSIX :: Linux
Operating System :: MacOS :: MacOS X
Operating System :: Microsoft :: Windows
"""
short_desc = "Read and write HDF5 files from Python"
long_desc = \
"""
The h5py package provides both a high- and low-level interface to the HDF5
library from Python. The low-level interface is intended to be a complete
wrapping of the HDF5 API, while the high-level component supports access to
HDF5 files, datasets and groups using established Python and NumPy concepts.
A strong emphasis on automatic conversion between Python (Numpy) datatypes and
data structures and their HDF5 equivalents vastly simplifies the process of
reading and writing data from Python.
Supports HDF5 versions 1.8.4 and higher. On Windows, HDF5 is included with
the installer.
"""
package_data = {'h5py': [], "h5py.tests.data_files": ["*.h5"]}
if os.name == 'nt':
package_data['h5py'].append('*.dll')
setup(
name = 'h5py',
version = VERSION,
description = short_desc,
long_description = long_desc,
classifiers = [x for x in cls_txt.split("\n") if x],
author = 'Andrew Collette',
author_email = '[email protected]',
maintainer = 'Andrew Collette',
maintainer_email = '[email protected]',
license = 'BSD',
url = 'http://www.h5py.org',
download_url = 'https://pypi.python.org/pypi/h5py',
packages = [
'h5py',
'h5py._hl',
'h5py.tests',
'h5py.tests.data_files',
'h5py.tests.test_vds',
],
package_data = package_data,
ext_modules = [Extension('h5py.x',['x.c'])], # To trick build into running build_ext
install_requires = RUN_REQUIRES,
setup_requires = SETUP_REQUIRES,
python_requires='>=3.7',
cmdclass = CMDCLASS,
)