[h5py] 88/455: setup.py tweaks
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Thu Jul 2 18:19:20 UTC 2015
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to annotated tag 1.3.0
in repository h5py.
commit 172919748a06a74bc6474fd4ee8d9096ae22494d
Author: andrewcollette <andrew.collette at gmail.com>
Date: Tue Jul 29 23:19:16 2008 +0000
setup.py tweaks
---
docs/info.txt | 4 +-
setup.py | 205 +++++++++++++++++++++++++++++++---------------------------
2 files changed, 110 insertions(+), 99 deletions(-)
diff --git a/docs/info.txt b/docs/info.txt
index b36ab13..0b87148 100644
--- a/docs/info.txt
+++ b/docs/info.txt
@@ -13,8 +13,8 @@ other thread can execute. Native-Python routines like those in h5py.highlevel
enforce thread safety through the use of reentrant locks.
Since HDF5 does not (yet) provide concurrency support for threads, the same
-global lock is used for all objects. It is available in the low-level
-component as h5.config.lock, and comes attached to all high-level objects
+global lock is used for all objects. It is available on the global config
+object as h5.config.lock, and comes attached to all high-level objects
(Dataset, etc.) as "<obj>.lock".
You are encouraged to use this locking mechanism for blocks of Python
diff --git a/setup.py b/setup.py
index 4cf0d0d..2134bd8 100644
--- a/setup.py
+++ b/setup.py
@@ -55,13 +55,6 @@ VERSION = '0.2.2'
MIN_PYREX = '0.9.8.4' # for compile_multiple
MIN_NUMPY = '1.0.3'
-# If you have your HDF5 *.h files and libraries somewhere not in /usr or
-# /usr/local, add that path here.
-custom_include_dirs = [] # = ["/some/other/path", "/an/other/path"]
-custom_library_dirs = []
-
-AUTO_HDR = "# This file is automatically generated. Do not edit."
-
# === Initial imports and utilities ===========================================
from distutils.cmd import Command
@@ -71,11 +64,7 @@ from distutils.extension import Extension
import os
import sys
import shutil
-
-# Distutils tries to use hard links when building source distributions, which
-# fails under a wide variety of network filesystems under Linux.
-if hasattr(os, 'link'):
- delattr(os, 'link') # goodbye!
+import os.path as op
def fatal(instring, code=1):
print >> sys.stderr, "Fatal: "+instring
@@ -86,46 +75,55 @@ def warn(instring):
# === Parse command line arguments ============================================
-ENABLE_PYREX = False # Flag: Pyrex must be run
-PYREX_ONLY = False # Flag: Run Pyrex, but don't perform build
-PYREX_FORCE = False # Flag: Disable Pyrex timestamp checking
-PYREX_FORCE_OFF = False # Flag: Don't run Pyrex, no matter what
+class CmdOptions(object):
+ pass
+opts = CmdOptions()
-API_VERS = (1,6)
-DEBUG_LEVEL = 0
-HDF5_DIR = None
-IO_NONBLOCK = False
+opts.AUTO_HDR = "# This file is automatically generated. Do not edit."
+opts.VERSION = VERSION
+opts.ENABLE_PYREX = False # Flag: Pyrex must be run
+opts.PYREX_ONLY = False # Flag: Run Pyrex, but don't perform build
+opts.PYREX_FORCE = False # Flag: Disable Pyrex timestamp checking
+opts.PYREX_FORCE_OFF = False # Flag: Don't run Pyrex, no matter what
+
+opts.API_MAJ = 1 # API interface version (not library version)
+opts.API_MIN = 6
+opts.DEBUG_LEVEL = 0 # Logging-module number, 0 to turn off
+opts.HDF5_DIR = None # Custom HDF5 directory, or None
+opts.IO_NONBLOCK = False # Experimental non-blocking I/O
for arg in sys.argv[:]:
if arg == '--pyrex':
- ENABLE_PYREX = True
+ opts.ENABLE_PYREX = True
sys.argv.remove(arg)
elif arg == '--pyrex-only':
- ENABLE_PYREX = True
- PYREX_ONLY = True
+ opts.ENABLE_PYREX = True
+ opts.PYREX_ONLY = True
sys.argv.remove(arg)
elif arg == '--pyrex-force':
- ENABLE_PYREX=True
- PYREX_FORCE = True
+ opts.ENABLE_PYREX=True
+ opts.PYREX_FORCE = True
sys.argv.remove(arg)
elif arg == '--no-pyrex':
- PYREX_FORCE_OFF = True
+ opts.PYREX_FORCE_OFF = True
sys.argv.remove(arg)
elif arg.find('--api=') == 0:
- ENABLE_PYREX=True
+ opts.ENABLE_PYREX=True
api = arg[6:]
if api == '16':
- API_VERS = (1,6)
+ opts.API_MAJ = 1
+ opts.API_MIN = 6
elif api == '18':
- API_VERS = (1,8)
+ opts.API_MAJ = 1
+ opts.API_MIN = 8
warn('1.8.X API is still under development')
else:
fatal('Unrecognized API version "%s" (only "16", "18" currently allowed)' % api)
sys.argv.remove(arg)
elif arg.find('--debug=') == 0:
- ENABLE_PYREX=True
+ opts.ENABLE_PYREX=True
try:
- DEBUG_LEVEL = int(arg[8:])
+ opts.DEBUG_LEVEL = int(arg[8:])
except:
fatal('Debuglevel not understood (wants --debug=<n>)')
sys.argv.remove(arg)
@@ -133,11 +131,11 @@ for arg in sys.argv[:]:
splitarg = arg.split('=',1)
if len(splitarg) != 2:
fatal("HDF5 directory not understood (wants --hdf5=/path/to/hdf5)")
- HDF5_DIR = splitarg[1]
+ opts.HDF5_DIR = splitarg[1]
sys.argv.remove(arg)
elif arg.find('--io-nonblock') == 0:
- ENABLE_PYREX=True
- IO_NONBLOCK = True
+ opts.ENABLE_PYREX=True
+ opts.IO_NONBLOCK = True
sys.argv.remove(arg)
if 'sdist' in sys.argv and os.path.exists('MANIFEST'):
@@ -159,45 +157,51 @@ try:
except ImportError:
fatal("Numpy not installed (version >= %s required)" % MIN_NUMPY)
-# === Setup configuration & Pyrex options =====================================
+# === Platform configuration & Pyrex check ====================================
-# Pyrex extension modules
-pyx_modules = ['h5' , 'h5f', 'h5g', 'h5s', 'h5t', 'h5d',
- 'h5a', 'h5p', 'h5z', 'h5i', 'h5r', 'h5fd', 'utils']
+# Pyrex modules (without extension)
+modules = ['h5' , 'h5f', 'h5g', 'h5s', 'h5t', 'h5d',
+ 'h5a', 'h5p', 'h5z', 'h5i', 'h5r', 'h5fd', 'utils']
-pyx_src_path = 'h5py'
-pyx_extra_src = ['utils_low.c'] # C source files required for Pyrex code
-pyx_libraries = ['hdf5'] # Libraries to link into Pyrex code
+# C source files required for Pyrex code (with extension)
+extra_src = ['utils_low.c']
-# Compile-time include and library dirs for Pyrex code
-pyx_include = [numpy.get_include()]
-if HDF5_DIR is None:
- pyx_include.extend(['/usr/include', '/usr/local/include'])
- pyx_include.extend(custom_include_dirs)
-else:
- pyx_include.extend([os.path.join(HDF5_DIR,'include')])
+# Where these live, relative to setup.py
+src_path = 'h5py'
+# Platform-dependent arguments to setup()
+if os.name == 'nt':
-if HDF5_DIR is None:
- pyx_library_dirs = ['/usr/lib', '/usr/local/lib']
- pyx_library_dirs.extend(custom_library_dirs)
-else:
- pyx_library_dirs = [os.path.join(HDF5_DIR, 'lib')]
+ if opts.HDF5_DIR is None:
+ fatal("On Windows, HDF5 directory must be specified.")
-# Additional compiler flags for Pyrex code
-pyx_extra_args = ['-Wno-unused', '-Wno-uninitialized', '-DH5_USE_16_API']
+ libraries = ['hdf5dll']
+ include_dirs = [numpy.get_include(), op.join(opts.HDF5_DIR, 'include')]
+ library_dirs = [op.join(opts.HDF5_DIR, 'dll2')] # Must contain only "hdf5dll.dll.a"
+ runtime_dirs = []
+ extra_compile_args = ['-DH5_USE_16_API', '-D_HDF5USEDLL_']
+ extra_link_args = []
-extra_link_args = []
-extra_compile_args = pyx_extra_args
+else:
-# Pyrex source files (without extension)
-pyrex_sources = [os.path.join(pyx_src_path, x) for x in pyx_modules]
+ libraries = ['hdf5']
+ if opts.HDF5_DIR is None:
+ include_dirs = [numpy.get_include(), '/usr/include', '/usr/local/include']
+ library_dirs = ['/usr/lib/', '/usr/local/lib']
+ else:
+ include_dirs = [numpy.get_include(), op.join(opts.HDF5_DIR, 'include')]
+ library_dirs = [op.join(opts.HDF5_DIR, 'lib')]
+ runtime_dirs = library_dirs
+ extra_compile_args = ['-DH5_USE_16_API', '-Wno-unused', '-Wno-uninitialized']
+ extra_link_args = []
# If for some reason the .c files are missing, Pyrex is required.
-if not all([os.path.exists(x+'.c') for x in pyrex_sources]):
- ENABLE_PYREX = True
+cfiles = [op.join(src_path, x+'.c') for x in modules]
+
+if not all( [op.exists(x) for x in cfiles]):
+ opts.ENABLE_PYREX = True
-if ENABLE_PYREX and not PYREX_FORCE_OFF:
+if opts.ENABLE_PYREX and not opts.PYREX_FORCE_OFF:
print "Running Pyrex..."
try:
@@ -207,23 +211,22 @@ if ENABLE_PYREX and not PYREX_FORCE_OFF:
from Pyrex.Compiler.Main import compile_multiple, CompilationOptions
# Check if the conditions.pxi file is up-to-date
- cond_path = os.path.join(pyx_src_path, 'conditions.pxi')
+ cond_path = op.join(src_path, 'conditions.pxi')
cond = \
"""
-%s
-
-DEF H5PY_VERSION = "%s"
-DEF H5PY_API_MAJ = %d
-DEF H5PY_API_MIN = %d
-DEF H5PY_DEBUG = %d
+%(AUTO_HDR)s
-DEF H5PY_16API = %d
-DEF H5PY_18API = %d
+DEF H5PY_VERSION = "%(VERSION)s"
+DEF H5PY_API_MAJ = %(API_MAJ)d
+DEF H5PY_API_MIN = %(API_MIN)d
+DEF H5PY_DEBUG = %(DEBUG_LEVEL)d
-DEF H5PY_NONBLOCK = %d
-""" % (AUTO_HDR, VERSION, API_VERS[0], API_VERS[1], DEBUG_LEVEL,
- 1 if API_VERS==(1,6) else 0, 1 if API_VERS==(1,8) else 0, int(IO_NONBLOCK))
+DEF H5PY_16API = H5PY_API_MIN == 6
+DEF H5PY_18API = H5PY_API_MIN == 8
+DEF H5PY_NONBLOCK = %(IO_NONBLOCK)d
+""" \
+ % opts.__dict__
try:
cond_file = open(cond_path,'r')
cond_present = cond_file.read()
@@ -239,12 +242,12 @@ DEF H5PY_NONBLOCK = %d
cond_file.write(cond)
cond_file.close()
- opts = CompilationOptions(verbose=True, timestamps=(not PYREX_FORCE))
- results = compile_multiple( [x+'.pyx' for x in pyrex_sources], opts)
+ pyxopts = CompilationOptions(verbose=True, timestamps=(not opts.PYREX_FORCE))
+ results = compile_multiple( [op.join(src_path,x+'.pyx') for x in modules], pyxopts)
if results.num_errors != 0:
fatal("%d Pyrex compilation errors encountered; aborting." % results.num_errors)
- if PYREX_ONLY:
+ if opts.PYREX_ONLY:
exit(0)
else:
fatal("Old Pyrex version %s detected (min %s)" % (Version.version, MIN_PYREX))
@@ -254,20 +257,20 @@ DEF H5PY_NONBLOCK = %d
else:
print "Skipping Pyrex..."
-# Create extensions
-pyx_extensions = []
-for module_name in pyx_modules:
- sources = [os.path.join(pyx_src_path, module_name) +'.c']
- sources += [os.path.join(pyx_src_path, x) for x in pyx_extra_src]
+# One extension is built for each module
+extensions = []
+for module in modules:
+ mod_sources = [op.join(src_path, module) +'.c']
+ mod_sources += [op.join(src_path, x) for x in extra_src]
- pyx_extensions.append(
+ extensions.append(
Extension(
- NAME+'.'+module_name,
- sources,
- include_dirs = pyx_include,
- libraries = pyx_libraries,
- library_dirs = pyx_library_dirs,
- runtime_library_dirs = pyx_library_dirs,
+ NAME+'.'+module,
+ mod_sources,
+ include_dirs = include_dirs,
+ libraries = libraries,
+ library_dirs = library_dirs,
+ runtime_library_dirs = runtime_dirs,
extra_compile_args = extra_compile_args,
extra_link_args = extra_link_args
)
@@ -289,7 +292,7 @@ class test(Command):
buildobj.run()
oldpath = sys.path
try:
- sys.path = [os.path.abspath(buildobj.build_lib)] + oldpath
+ sys.path = [op.abspath(buildobj.build_lib)] + oldpath
import h5py.tests
if not h5py.tests.runtests():
raise DistutilsError("Unit tests failed.")
@@ -297,6 +300,7 @@ class test(Command):
sys.path = oldpath
class dev(Command):
+
description = "Developer commands (--doc, --clean, --readme=<file>)"
user_options = [('doc','d','Rebuild documentation'),
('readme=','r','Compile HTML file from README.txt'),
@@ -318,8 +322,8 @@ class dev(Command):
shutil.rmtree(x)
except OSError:
pass
- fnames = [ x+'.dep' for x in pyrex_sources ] + \
- [ x+'.c' for x in pyrex_sources ] + \
+ fnames = [ op.join(src_path, x+'.dep') for x in modules ] + \
+ [ op.join(src_path, x+'.c') for x in modules ] + \
[ 'MANIFEST']
for name in fnames:
@@ -331,7 +335,7 @@ class dev(Command):
if self.doc:
buildobj = self.distribution.get_command_obj('build')
buildobj.run()
- if not os.path.exists('docs/html'):
+ if not op.exists('docs/html'):
os.mkdir('docs', 0755)
os.mkdir('docs/html', 0755)
@@ -350,9 +354,16 @@ class dev(Command):
fh.write(parts['body'])
fh.close()
-# Add these to the command class dictionary for setup()
-CMD_CLASS = {'dev': dev, 'test': test}
+# New commands for setup (e.g. "python setup.py test")
+if os.name == 'nt':
+ CMD_CLASS = {'test': test}
+else:
+ CMD_CLASS = {'dev': dev, 'test': test}
+#print "Configuration"
+#print '-'*40
+#for key in sorted(opts.__dict__):
+# print "%-20s %s" % (key, opts.__dict__[key])
# Run setup
setup(
@@ -362,8 +373,8 @@ setup(
url = 'h5py.alfven.org',
packages = ['h5py','h5py.tests'],
package_data = {'h5py': ['*.pyx'], # so source is available for tracebacks
- 'h5py.tests': ['data/*.hdf5']},
- ext_modules = pyx_extensions,
+ 'h5py.tests': ['data/*.hdf5']}, # Should be / even on Windows
+ ext_modules = extensions,
requires = ['numpy (>=1.0.3)'],
provides = ['h5py'],
cmdclass = CMD_CLASS
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/h5py.git
More information about the debian-science-commits
mailing list