[h5py] 192/455: Fixes for setup (sudo sometimes ignores environment variables)
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Thu Jul 2 18:19:31 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 77fa55ec0922286611602427600a840ec2342459
Author: andrewcollette <andrew.collette at gmail.com>
Date: Fri Jan 23 00:42:44 2009 +0000
Fixes for setup (sudo sometimes ignores environment variables)
---
INSTALL.txt | 23 ++++++++++++-----
setup.py | 86 ++++++++++++++++++++++++++++++++++++++++++++-----------------
2 files changed, 80 insertions(+), 29 deletions(-)
diff --git a/INSTALL.txt b/INSTALL.txt
index e452d2f..66a8ab0 100644
--- a/INSTALL.txt
+++ b/INSTALL.txt
@@ -34,14 +34,25 @@ Custom options
Sometimes h5py may not be able to determine what version of HDF5 is installed.
Also, sometimes HDF5 may be installed in an unusual location. You can
-specify both your version of HDF5 and its location through environment
-variables:
+specify both your version of HDF5 and its location through the "configure"
+command:
- $ export HDF5_DIR=/path/to/hdf5
- $ export HDF5_API=<16 or 18>
+ $ python setup.py configure [--hdf5=/path/to/hdf5] [--api=<16 or 18>]
+ $ python setup.py build
+ $ [sudo] python setup.py install
-These options will work for both easy_install and manual installation.
-Both are optional.
+Alternatively (for example, if installing with easy_install), you can use
+environment variables:
+
+ $ su
+ # export HDF5_DIR=/path/to/hdf5
+ # export HDF5_API=<16 or 18>
+ # easy_install h5py
+
+Keep in mind that on some platforms, "sudo" will filter out your environment
+variables, so it's best to set them in a root shell as above. If environment
+variables already exist and the "configure" command is run, the settings
+from "configure" take priority.
Running tests
diff --git a/setup.py b/setup.py
index e938790..df54052 100644
--- a/setup.py
+++ b/setup.py
@@ -23,6 +23,7 @@ import sys
import shutil
import commands
import os.path as op
+import pickle
NAME = 'h5py'
VERSION = '1.1.0'
@@ -116,17 +117,8 @@ class GlobalOpts:
def __init__(self):
- wstr = \
-"""
-*******************************************************************************
- Command-line options --hdf5 and --api are deprecated and will be removed
- from setup.py in the next minor release of h5py.
-
- Please use the environment variables HDF5_DIR and HDF5_API instead:
- $ export HDF5_DIR=/path/to/hdf5
- $ export HDF5_API=<16 or 18>
-*******************************************************************************\
-"""
+ # Environment variables are the only way to communicate this
+ # information if we're building with easy_install
hdf5 = os.environ.get("HDF5_DIR", None)
if hdf5 == '': hdf5 = None
if hdf5 is not None:
@@ -137,16 +129,20 @@ class GlobalOpts:
if api is not None:
debug("Found environ var HDF5_API=%s" % api)
- # For backwards compatibility
- for arg in sys.argv[:]:
- if arg.find('--hdf5=') == 0:
- hdf5 = arg.partition('=')[2]
- sys.argv.remove(arg)
- warn(wstr)
- if arg.find('--api=') == 0:
- self.api = arg.partition('=')[2]
- sys.argv.remove(arg)
- warn(wstr)
+ # The output of the "configure" command is preferred
+ try:
+ f = open(localpath('buildconf.pickle'),'r')
+ hdf5_pkl, api_pkl = pickle.load(f)
+ f.close()
+ except Exception:
+ pass
+ else:
+ if hdf5_pkl is not None:
+ hdf5 = hdf5_pkl
+ debug("Loaded HDF5 dir %s from pickle file" % hdf5)
+ if api_pkl is not None:
+ api = api_pkl
+ debug("Loaded API %s from pickle file" % api)
if hdf5 is not None and not op.isdir(hdf5):
fatal('Invalid HDF5 path "%s"' % hdf5)
@@ -248,10 +244,50 @@ EXTENSIONS = [creator.create_extension(x, EXTRA_SRC.get(x, None)) for x in MODUL
# --- Custom extensions for distutils -----------------------------------------
+class configure(Command):
+
+ description = "Set options for your HDF5 installation"
+
+ user_options = [('hdf5=', '5', 'Path to HDF5'),
+ ('api=', 'a', 'API version ("16" or "18")'),
+ ('show', 's', 'Print existing config (don\'t set anything)')]
+
+ boolean_options = ['show']
+
+ def initialize_options(self):
+ self.hdf5 = None
+ self.api = None
+ self.show = False
+
+ def finalize_options(self):
+ pass
+
+ def run(self):
+ if self.show:
+ try:
+ f = open('buildconf.pickle','r')
+ hdf5, api = pickle.load(f)
+ except Exception:
+ hdf5 = api = None
+ print "HDF5 path: %s\nAPI setting: %s" % (hdf5, api)
+ return
+
+ if self.hdf5 is not None and not op.isdir(self.hdf5):
+ fatal("Invalid HDF5 path: %s" % self.hdf5)
+ self.hdf5 = op.abspath(self.hdf5)
+ if self.api is not None and self.api not in ('16','18'):
+ fatal("Invalid API level %s (must be 16 or 18)" % self.api)
+
+ f = open('buildconf.pickle','w')
+ pickle.dump((self.hdf5, self.api), f)
+ f.close()
+
class cython(Command):
""" Cython pre-builder """
+ description = "Rebuild Cython-generated C files"
+
user_options = [('diag', 'd', 'Enable library debug logging'),
('api16', '6', 'Only build version 1.6'),
('api18', '8', 'Only build version 1.8'),
@@ -395,7 +431,9 @@ class cleaner(clean):
def run(self):
c_files = [localpath(SRC_PATH, x+'.c') for x in MODULES]
so_files = [localpath(SRC_PATH, x+'.so') for x in MODULES]
- for path in c_files+so_files:
+ ext_files = [localpath('buildconf.pickle')]
+
+ for path in c_files+so_files+ext_files:
try:
os.remove(path)
except Exception:
@@ -404,7 +442,8 @@ class cleaner(clean):
debug("Cleaning up %s" % path)
clean.run(self)
-CMD_CLASS = {'cython': cython, 'build_ext': hbuild_ext, 'clean': cleaner}
+CMD_CLASS = {'cython': cython, 'build_ext': hbuild_ext, 'clean': cleaner,
+ 'configure': configure}
# --- Setup parameters --------------------------------------------------------
@@ -469,3 +508,4 @@ setup(
+
--
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