summaryrefslogtreecommitdiff
path: root/python/setup.py
diff options
context:
space:
mode:
authorKenneth Heafield <github@kheafield.com>2012-08-03 07:46:54 -0400
committerKenneth Heafield <github@kheafield.com>2012-08-03 07:46:54 -0400
commitbe1ab0a8937f9c5668ea5e6c31b798e87672e55e (patch)
treea13aad60ab6cced213401bce6a38ac885ba171ba /python/setup.py
parente5d6f4ae41009c26978ecd62668501af9762b0bc (diff)
parent9fe0219562e5db25171cce8776381600ff9a5649 (diff)
Merge branch 'master' of github.com:redpony/cdec
Diffstat (limited to 'python/setup.py')
-rw-r--r--python/setup.py48
1 files changed, 36 insertions, 12 deletions
diff --git a/python/setup.py b/python/setup.py
index 49a1ec8f..7be976e8 100644
--- a/python/setup.py
+++ b/python/setup.py
@@ -1,29 +1,53 @@
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']
-LIB = ['../decoder', '../utils', '../mteval', '../klm/lm', '../klm/util']
+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'],
- language='C++',
+ Extension(name='cdec._cdec',
+ sources=['src/_cdec.cpp'],
include_dirs=INC,
library_dirs=LIB,
- libraries=['boost_program_options-mt', 'z',
- 'cdec', 'utils', 'mteval', 'klm', 'klm_util'])
+ libraries=[BOOST_PROGRAM_OPTIONS, 'z',
+ 'cdec', 'utils', 'mteval', 'training', 'klm', 'klm_util'],
+ extra_compile_args=['-DHAVE_CONFIG_H'],
+ extra_link_args=LINK_ARGS),
+ Extension(name='cdec.sa._sa',
+ sources=['src/sa/_sa.c', 'src/sa/strmap.cc'])
]
setup(
name='cdec',
- cmdclass={'build_ext': build_ext},
ext_modules=ext_modules,
- packages=['cdec', 'cdec.scfg']
+ requires=['configobj'],
+ packages=['cdec', 'cdec.sa'],
+ package_dir={'': 'pkg'}
)