diff --git a/src/bindings/python/SConscript b/src/bindings/python/SConscript index 0f1e9a92e5215fcb03547a3e075411e36bf2a949..0a905b7a6341bcc014a91658ce77b9b77a99fb4c 100644 --- a/src/bindings/python/SConscript +++ b/src/bindings/python/SConscript @@ -4,18 +4,20 @@ Import('env libhammer_shared testruns') pythonenv = env.Clone(IMPLICIT_COMMAND_DEPENDENCIES = 0) -pythonenv.Append(CPPPATH = ['../../']) -pythonenv.Append(CCFLAGS = ['-fpic', '-DSWIG', '-Wno-all', '-Wno-extra', '-Wno-error']) -pythonenv.ParseConfig("pkg-config --cflags python") -pythonenv.Append(LIBS = ['hammer']) -pythonenv.Append(LIBPATH = ['../../']) -pythonenv.Append(SWIGFLAGS = ['-DHAMMER_INTERNAL__NO_STDARG_H', '-Isrc/', '-python']) +#pythonenv.Append(CPPPATH = ['../../']) +#pythonenv.Append(CCFLAGS = ['-fpic', '-DSWIG', '-Wno-all', '-Wno-extra', '-Wno-error']) +#pythonenv.ParseConfig("pkg-config --cflags python") +#pythonenv.Append(LIBS = ['hammer']) +#pythonenv.Append(LIBPATH = ['../../']) +#pythonenv.Append(SWIGFLAGS = ['-DHAMMER_INTERNAL__NO_STDARG_H', '-Isrc/', '-python']) -pythonenv.Command("hammer.i", "../swig/hammer.i", Copy("$TARGET", "$SOURCE")) -swig = ['hammer.i'] -libhammer_python = pythonenv.SharedLibrary('hammer', swig, SHLIBPREFIX='_') +swig = pythonenv.Command("hammer.i", "../swig/hammer.i", Copy("$TARGET", "$SOURCE")) +setup = ['setup.py'] +pydir = os.path.join(env['BUILD_BASE'], 'src/bindings/python') +#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"') Default(libhammer_python) pytestenv = pythonenv.Clone() diff --git a/src/bindings/python/setup.py b/src/bindings/python/setup.py index 362b2529ddecd4d42622924665414f5a66a417f3..2f42fa060a29f71d4ab9f7c7e026ea2e4c5eeeb5 100644 --- a/src/bindings/python/setup.py +++ b/src/bindings/python/setup.py @@ -3,20 +3,28 @@ """ setup.py for Hammer bindings """ - +import os.path, sys from distutils.core import setup, Extension setup(name="hammer", version="0.9.0", author="Upstanding Hackers, LLC", + author_email="hammer@upstandinghackers.com", + url="https://github.com/UpstandingHackers/hammer", description="""The Hammer parser combinator library""", - ext_modules=[Extension('_hammer', ['hammer.i'], - swig_opts=['-DHAMMER_INTERNAL__NO_STDARG_H', '-I../../'], - define_macros = [('SWIG', None)], - extra_compile_args = ['-fPIC', - '-std=gnu99',], - include_dirs=['../../'], - library_dirs=['../../'], + ext_modules=[Extension('_hammer', [os.path.join(os.path.dirname(sys.argv[0]), + 'hammer.i')], + # swig_opts is set by SConscript + define_macros=[('SWIG', None)], + depends=['allocator.h', + 'glue.h', + 'hammer.h', + 'internal.h',], + extra_compile_args=['-fPIC', + '-std=gnu99',], + include_dirs=['src'], + library_dirs=['src'], libraries=['hammer'],)], + py_modules=['hammer'], )