2012-01-06 08:55:05 -06:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
"""
|
2016-03-18 19:48:47 -06:00
|
|
|
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.
|
2012-01-06 08:55:05 -06:00
|
|
|
"""
|
|
|
|
|
|
|
|
try:
|
2016-03-18 19:48:47 -06:00
|
|
|
from setuptools import Extension, setup
|
2012-01-06 08:55:05 -06:00
|
|
|
except ImportError:
|
2016-03-18 19:48:47 -06:00
|
|
|
from distutils.core import setup
|
|
|
|
from distutils.extension import Extension
|
2012-01-06 08:55:05 -06:00
|
|
|
from distutils.cmd import Command
|
2016-03-18 19:48:47 -06:00
|
|
|
from distutils.dist import Distribution
|
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
import os.path as op
|
2012-01-06 08:55:05 -06:00
|
|
|
|
2016-03-18 19:48:47 -06:00
|
|
|
import setup_build, setup_configure
|
2012-01-06 08:55:05 -06:00
|
|
|
|
|
|
|
|
2016-03-18 19:48:47 -06:00
|
|
|
VERSION = '2.6.0'
|
2012-01-06 08:55:05 -06:00
|
|
|
|
2016-03-18 19:48:47 -06:00
|
|
|
NUMPY_DEP = 'numpy>=1.6.1'
|
2012-01-06 08:55:05 -06:00
|
|
|
|
2016-03-18 19:48:47 -06:00
|
|
|
# these are required to use h5py
|
|
|
|
RUN_REQUIRES = [NUMPY_DEP, 'six']
|
2012-01-06 08:55:05 -06:00
|
|
|
|
2016-03-18 19:48:47 -06:00
|
|
|
# these are required to build h5py
|
|
|
|
# RUN_REQUIRES is included as setup.py test needs RUN_REQUIRES for testing
|
|
|
|
# RUN_REQUIRES can be removed when setup.py test is removed
|
|
|
|
SETUP_REQUIRES = RUN_REQUIRES + [NUMPY_DEP, 'Cython>=0.19', 'pkgconfig']
|
2012-01-06 08:55:05 -06:00
|
|
|
|
|
|
|
|
2016-03-18 19:48:47 -06:00
|
|
|
# --- Custom Distutils commands -----------------------------------------------
|
2012-01-06 08:55:05 -06:00
|
|
|
|
2016-03-18 19:48:47 -06:00
|
|
|
class test(Command):
|
2012-01-06 08:55:05 -06:00
|
|
|
|
2016-03-18 19:48:47 -06:00
|
|
|
"""
|
|
|
|
Custom Distutils command to run the h5py test suite.
|
2012-01-06 08:55:05 -06:00
|
|
|
|
2016-03-18 19:48:47 -06:00
|
|
|
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.
|
|
|
|
"""
|
2012-01-06 08:55:05 -06:00
|
|
|
|
2016-03-18 19:48:47 -06:00
|
|
|
description = "Run the test suite"
|
2012-01-06 08:55:05 -06:00
|
|
|
|
2016-03-18 19:48:47 -06:00
|
|
|
user_options = [('detail', 'd', 'Display additional test information')]
|
2012-01-06 08:55:05 -06:00
|
|
|
|
|
|
|
def initialize_options(self):
|
2016-03-18 19:48:47 -06:00
|
|
|
self.detail = False
|
2012-01-06 08:55:05 -06:00
|
|
|
|
|
|
|
def finalize_options(self):
|
2016-03-18 19:48:47 -06:00
|
|
|
self.detail = bool(self.detail)
|
2012-01-06 08:55:05 -06:00
|
|
|
|
|
|
|
def run(self):
|
2016-03-18 19:48:47 -06:00
|
|
|
""" Called by Distutils when this command is run """
|
|
|
|
import sys
|
|
|
|
py_version = sys.version_info[:2]
|
|
|
|
if py_version != (2, 6):
|
|
|
|
import unittest
|
2012-01-06 08:55:05 -06:00
|
|
|
else:
|
|
|
|
try:
|
2016-03-18 19:48:47 -06:00
|
|
|
import unittest2 as unittest
|
|
|
|
except ImportError:
|
|
|
|
raise ImportError( "unittest2 is required to run tests with Python 2.6")
|
2012-01-06 08:55:05 -06:00
|
|
|
|
|
|
|
buildobj = self.distribution.get_command_obj('build')
|
|
|
|
buildobj.run()
|
2016-03-18 19:48:47 -06:00
|
|
|
|
|
|
|
oldpath = sys.path
|
|
|
|
try:
|
|
|
|
sys.path = [op.abspath(buildobj.build_lib)] + oldpath
|
|
|
|
import h5py
|
|
|
|
result = h5py.run_tests(verbose=self.detail)
|
|
|
|
if not result.wasSuccessful():
|
|
|
|
sys.exit(1)
|
|
|
|
finally:
|
|
|
|
sys.path = oldpath
|
|
|
|
|
|
|
|
|
|
|
|
CMDCLASS = {'build_ext': setup_build.h5py_build_ext,
|
|
|
|
'configure': setup_configure.configure,
|
|
|
|
'test': test, }
|
2012-01-06 08:55:05 -06:00
|
|
|
|
|
|
|
|
2016-03-18 19:48:47 -06:00
|
|
|
# --- Distutils setup and metadata --------------------------------------------
|
2012-01-06 08:55:05 -06:00
|
|
|
|
|
|
|
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 :: Python
|
|
|
|
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.
|
|
|
|
|
2016-03-18 19:48:47 -06:00
|
|
|
Supports HDF5 versions 1.8.4 and higher. On Windows, HDF5 is included with
|
2012-01-06 08:55:05 -06:00
|
|
|
the installer.
|
|
|
|
"""
|
|
|
|
|
|
|
|
if os.name == 'nt':
|
2016-03-18 19:48:47 -06:00
|
|
|
package_data = {'h5py': ['*.dll']}
|
2012-01-06 08:55:05 -06:00
|
|
|
else:
|
2016-03-18 19:48:47 -06:00
|
|
|
package_data = {'h5py': []}
|
2012-01-06 08:55:05 -06:00
|
|
|
|
|
|
|
setup(
|
|
|
|
name = 'h5py',
|
2016-03-18 19:48:47 -06:00
|
|
|
version = VERSION,
|
2012-01-06 08:55:05 -06:00
|
|
|
description = short_desc,
|
|
|
|
long_description = long_desc,
|
|
|
|
classifiers = [x for x in cls_txt.split("\n") if x],
|
|
|
|
author = 'Andrew Collette',
|
2016-03-18 19:48:47 -06:00
|
|
|
author_email = 'andrew dot collette at gmail dot com',
|
2012-01-06 08:55:05 -06:00
|
|
|
maintainer = 'Andrew Collette',
|
2016-03-18 19:48:47 -06:00
|
|
|
maintainer_email = 'andrew dot collette at gmail dot com',
|
|
|
|
url = 'http://www.h5py.org',
|
|
|
|
download_url = 'https://pypi.python.org/pypi/h5py',
|
|
|
|
packages = ['h5py', 'h5py._hl', 'h5py.tests', 'h5py.tests.old', 'h5py.tests.hl'],
|
2012-01-06 08:55:05 -06:00
|
|
|
package_data = package_data,
|
2016-03-18 19:48:47 -06:00
|
|
|
ext_modules = [Extension('h5py.x',['x.c'])], # To trick build into running build_ext
|
|
|
|
install_requires = RUN_REQUIRES,
|
|
|
|
setup_requires = SETUP_REQUIRES,
|
|
|
|
cmdclass = CMDCLASS,
|
2012-01-06 08:55:05 -06:00
|
|
|
)
|