diff options
author | Wilker Aziz <wilker.aziz@gmail.com> | 2012-09-14 13:59:18 +0400 |
---|---|---|
committer | Wilker Aziz <wilker.aziz@gmail.com> | 2012-09-14 13:59:18 +0400 |
commit | 629805a90a8d7a9d684040f74b1f889c3d1933d9 (patch) | |
tree | 2a59e0fcb395740c8f1b7adca147bb457f6fb831 /contrib/python | |
parent | 73031002ba2e71415d8b7ef825d3680cad7ff8ae (diff) |
Added an option to use/not use cmph and details about building/compiling in README
Diffstat (limited to 'contrib/python')
-rw-r--r-- | contrib/python/README.md | 15 | ||||
-rw-r--r-- | contrib/python/setup.py | 17 |
2 files changed, 24 insertions, 8 deletions
diff --git a/contrib/python/README.md b/contrib/python/README.md index d3f023882..4535dae33 100644 --- a/contrib/python/README.md +++ b/contrib/python/README.md @@ -1,6 +1,6 @@ # Python interface to Moses -The idea is to have some of Moses' internals exposed to Python (inspired by pycdec). +The idea is to have some of Moses' internals exposed to Python (inspired on pycdec). ## What's been interfaced? @@ -9,11 +9,8 @@ The idea is to have some of Moses' internals exposed to Python (inspired by pycd Moses::PhraseDictionaryTree.h ## Building -1. Compile the cython code - cython --cplus binpt/binpt.pyx - -2. Build the python extension +1. Build the python extension python setup.py build_ext -i @@ -21,3 +18,11 @@ The idea is to have some of Moses' internals exposed to Python (inspired by pycd echo '! " and "' | python example.py bin-ptable-stem 5 1 echo "casa" | python example.py bin-ptable-stem 5 + +## Changing the code + +If you want to add your changes you are going to have to recompile the cython code. + +1. Compile the cython code (use Cython 0.16): this will generate binpt/binpt.cpp + + cython --cplus binpt/binpt.pyx diff --git a/contrib/python/setup.py b/contrib/python/setup.py index afa4d552a..e211e0f34 100644 --- a/contrib/python/setup.py +++ b/contrib/python/setup.py @@ -2,12 +2,23 @@ from distutils.core import setup from distutils.extension import Extension import os +#### Check if you agree with these settings +with_cmph = True + + +#### From here you probably don't need to change anything +#### unless a new dependency shows up in Moses + mosesdir = os.path.abspath('../../') includes = [mosesdir, os.path.join(mosesdir, 'moses/src'), os.path.join(mosesdir, 'util')] - libdir = os.path.join(mosesdir, 'lib') -basic=['z', 'stdc++', 'pthread', 'm', 'gcc_s', 'c', 'boost_system', 'boost_thread', 'boost_filesystem', 'rt', 'cmph'] + +basic=['z', 'stdc++', 'pthread', 'm', 'gcc_s', 'c', 'boost_system', 'boost_thread', 'boost_filesystem', 'rt'] moses=['OnDiskPt', 'kenutil', 'kenlm', 'LM', 'mert_lib', 'moses_internal', 'CYKPlusParser', 'Scope3Parser', 'fuzzy-match', 'RuleTable', 'CompactPT', 'moses', 'dynsa', 'pcfg_common' ] +additional=[] + +if with_cmph: + additional.append('cmph') exobj = [os.path.join(libdir, 'lib' + l + '.so') for l in moses] @@ -19,7 +30,7 @@ ext_modules = [ extra_objects = exobj, library_dirs = [libdir], runtime_library_dirs = [libdir], - libraries = basic + moses, + libraries = basic + moses + additional, extra_compile_args = ['-O3', '-DNDEBUG'], ) ] |