Skip to content

Instantly share code, notes, and snippets.

@joshmoore
Created August 26, 2011 22:19
Show Gist options
  • Save joshmoore/1174568 to your computer and use it in GitHub Desktop.
Save joshmoore/1174568 to your computer and use it in GitHub Desktop.
PyTables script to be run during continuous integration (cross-platform)
import os
import re
import sys
import subprocess
import platform
venv = os.environ.get("VIRTUALENV", "default")
if platform.system() == "Windows":
home = "C:\\hudson"
bin = "Scripts"
exe = ".exe"
win32 = True
else:
home = os.path.expanduser("~")
bin = "bin"
exe = ""
win32 = False
bindir = os.path.join(home, venv, bin)
python = os.path.join(bindir, "python" + exe)
nosetests = os.path.join(bindir, "nosetests" + exe)
coverage = os.path.join(bindir, "coverage" + exe )
print "Using %s..." % python
os.environ["PATH"] = os.path.pathsep.join([bindir, os.environ["PATH"]])
try:
os.environ["PYTHONPATH"] = os.path.pathsep.join([".", os.environ["PYTHONPATH"]])
except KeyError:
os.environ["PYTHONPATH"] = "."
def call(*args):
cmd = list(args)
rc = subprocess.call(cmd)
if rc != 0:
print >>sys.stderr, "FAILED: '%s'" % " ".join(cmd)
sys.exit(rc)
build_ext = [python, 'setup.py', 'build_ext', '--inplace']
build_win = [python, 'setup.py', 'bdist_wininst']
if "HDF5_DIR" not in os.environ:
build_ext.append("--hdf5=/usr")
call(*build_ext)
if win32:
call(*build_win)
TESTS = 'tables/tests/test_all.py'
call(nosetests, '--with-xunit', '--with-coverage', TESTS)
call(coverage, 'xml')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment