distutils and working tests!

This commit is contained in:
Meredith L. Patterson 2013-11-26 19:25:41 -08:00
parent 53bc886e2f
commit 20bf8c4b79
2 changed files with 14 additions and 8 deletions

View file

@ -17,13 +17,13 @@ swig = pythonenv.Command("hammer.i", "../swig/hammer.i", Copy("$TARGET", "$SOURC
setup = ['setup.py'] setup = ['setup.py']
pydir = os.path.join(env['BUILD_BASE'], 'src/bindings/python') pydir = os.path.join(env['BUILD_BASE'], 'src/bindings/python')
#libhammer_python = pythonenv.SharedLibrary('hammer', swig, SHLIBPREFIX='_') #libhammer_python = pythonenv.SharedLibrary('hammer', swig, SHLIBPREFIX='_')
libhammer_python = pythonenv.Command(None, [swig, setup], 'python ' + os.path.join(pydir, 'setup.py') + ' build_ext --swig-opts="-outdir ' + pydir + ' -DHAMMER_INTERNAL__NO_STDARG_H -Isrc"') libhammer_python = pythonenv.Command(['hammer.py', 'hammer_wrap.c'], [swig, setup], 'python ' + os.path.join(pydir, 'setup.py') + ' build_ext --inplace')
Default(libhammer_python) Default(libhammer_python)
pytestenv = pythonenv.Clone() pytestenv = pythonenv.Clone()
pytestenv['ENV']['LD_LIBRARY_PATH'] = os.path.dirname(str(libhammer_shared[0])) pytestenv['ENV']['LD_LIBRARY_PATH'] = os.path.dirname(str(libhammer_shared[0]))
pytests = ['hammer_tests.py'] pytests = ['hammer_tests.py']
pytestexec = pytestenv.Command(['hammer.pyc', 'hammer_tests.pyc'], pytests + libhammer_python, "nosetests -vv $SOURCE") pytestexec = pytestenv.Command(['hammer.pyc', 'hammer_tests.pyc'], pytests + libhammer_python, "LD_LIBRARY_PATH=" + os.path.dirname(str(libhammer_shared[0])) + " nosetests -vv $SOURCE")
pytest = Alias("testpython", [pytestexec], pytestexec) pytest = Alias("testpython", [pytestexec], pytestexec)
AlwaysBuild(pytest) AlwaysBuild(pytest)
testruns.append(pytest) testruns.append(pytest)

View file

@ -3,18 +3,22 @@
""" """
setup.py for Hammer bindings setup.py for Hammer bindings
""" """
import os.path, sys import os, os.path, sys
from distutils.core import setup, Extension from distutils.core import setup, Extension
invoked = os.getcwd()
os.chdir(os.path.dirname(sys.argv[0]))
setup(name="hammer", setup(name="hammer",
version="0.9.0", version="0.9.0",
author="Upstanding Hackers, LLC", author="Upstanding Hackers, LLC",
author_email="hammer@upstandinghackers.com", author_email="hammer@upstandinghackers.com",
url="https://github.com/UpstandingHackers/hammer", url="https://github.com/UpstandingHackers/hammer",
description="""The Hammer parser combinator library""", description="""The Hammer parser combinator library""",
ext_modules=[Extension('_hammer', [os.path.join(os.path.dirname(sys.argv[0]), ext_modules=[Extension('_hammer', ['hammer.i'],
'hammer.i')], swig_opts=['-DHAMMER_INTERNAL__NO_STDARG_H',
# swig_opts is set by SConscript #('-outdir', os.getcwd()),
'-I../../'],
define_macros=[('SWIG', None)], define_macros=[('SWIG', None)],
depends=['allocator.h', depends=['allocator.h',
'glue.h', 'glue.h',
@ -22,9 +26,11 @@ setup(name="hammer",
'internal.h',], 'internal.h',],
extra_compile_args=['-fPIC', extra_compile_args=['-fPIC',
'-std=gnu99',], '-std=gnu99',],
include_dirs=['src'], include_dirs=['../../'],
library_dirs=['src'], library_dirs=['../../'],
libraries=['hammer'],)], libraries=['hammer'],)],
py_modules=['hammer'], py_modules=['hammer'],
) )
os.chdir(invoked)