diff options
author | Victor Chahuneau <vchahune@cs.cmu.edu> | 2012-07-21 01:22:53 -0400 |
---|---|---|
committer | Victor Chahuneau <vchahune@cs.cmu.edu> | 2012-07-21 01:22:53 -0400 |
commit | 06f90d83a1feafad301d365a4a437e44f68be45b (patch) | |
tree | 24128de1cb5a4767151f9380c46104a26121535d /python/setup.py | |
parent | c4c9c2febd5af552ecddc215758e32b88013fbc7 (diff) |
[python] Support for grammars
- Translation rules can now be create programatically
- Grammars = list of translation rules can be used for translation
- Feature expectations on the hypergraph (inside_outside)
Diffstat (limited to 'python/setup.py')
-rw-r--r-- | python/setup.py | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/python/setup.py b/python/setup.py index cc8b289d..701841a4 100644 --- a/python/setup.py +++ b/python/setup.py @@ -1,30 +1,50 @@ from distutils.core import setup from distutils.extension import Extension -from Cython.Distutils import build_ext +import sys import os +import glob INC = ['..', 'src/', '../decoder', '../utils', '../mteval'] LIB = ['../decoder', '../utils', '../mteval', '../training', '../klm/lm', '../klm/util'] +LINK_ARGS = [] +# Detect Boost BOOST_ROOT = os.getenv('BOOST_ROOT') if BOOST_ROOT: - INC.append(os.path.join(BOOST_ROOT, 'include/')) - LIB.append(os.path.join(BOOST_ROOT, 'lib/')) + BOOST_INC = os.path.join(BOOST_ROOT, 'include') + BOOST_LIB = os.path.join(BOOST_ROOT, 'lib') + if not os.path.exists(BOOST_INC): + sys.stderr.write('Error: could not find Boost headers in <%s>\n' % BOOST_INC) + sys.exit(1) + if not os.path.exists(BOOST_LIB): + sys.stderr.write('Error: could not find Boost libraries in <%s>\n' % BOOST_LIB) + sys.exit(1) + INC.append(BOOST_INC) + LIB.append(BOOST_LIB) + LINK_ARGS += ['-Wl,-rpath', '-Wl,'+BOOST_LIB] +else: + BOOST_LIB = '/usr/local/lib' + +# Detect -mt +if glob.glob(os.path.join(BOOST_LIB, 'libboost_program_options-mt.*')): + BOOST_PROGRAM_OPTIONS = 'boost_program_options-mt' +else: + BOOST_PROGRAM_OPTIONS = 'boost_program_options' ext_modules = [ Extension(name='_cdec', - sources=['src/_cdec.pyx'], + sources=['src/_cdec.cpp'], language='C++', include_dirs=INC, library_dirs=LIB, - libraries=['boost_program_options-mt', 'z', + libraries=[BOOST_PROGRAM_OPTIONS, 'z', 'cdec', 'utils', 'mteval', 'training', 'klm', 'klm_util'], - extra_compile_args=['-DHAVE_CONFIG_H']), + extra_compile_args=['-DHAVE_CONFIG_H'], + extra_link_args=LINK_ARGS), ] setup( name='cdec', - cmdclass={'build_ext': build_ext}, ext_modules=ext_modules, packages=['cdec', 'cdec.scfg'] ) |