commit 5916c0ddb93d01fd1b6ddcbbcd940d833068546a Author: vaydheesh Date: Tue Jun 25 16:09:50 2019 +0530 Improved parsing of CFLAGS diff --git a/.gitignore b/.gitignore index b05bf2d..a70a55d 100644 --- a/.gitignore +++ b/.gitignore @@ -58,7 +58,7 @@ lrx-comp lrx-proc lrx_config.h -lrx_config.h.in +lrx_config.h.in* multitrans stamp-h1 diff --git a/python/lex_tools.i b/python/lex_tools.i index 5112d64..2645171 100644 --- a/python/lex_tools.i +++ b/python/lex_tools.i @@ -19,8 +19,8 @@ void LRX::lrx_proc(char arg, char *dictionary_path, char *input_path, char *output_path) { bool useMaxEnt = false; - FILE *in = fopen(dictionary_path, "rb"); - load(in); + FILE *dictionary = fopen(dictionary_path, "rb"); + load(dictionary); FILE *input = fopen(input_path, "r"), *output = fopen(output_path, "w"); switch(arg) { @@ -39,7 +39,7 @@ LRX::lrx_proc(char arg, char *dictionary_path, char *input_path, char *output_pa { process(input, output); } - fclose(in); + fclose(dictionary); fclose(input); fclose(output); } @@ -48,6 +48,7 @@ LRX::lrx_proc(char arg, char *dictionary_path, char *input_path, char *output_pa %include +%include class LRX: public LRXProcessor diff --git a/python/setup.py.in b/python/setup.py.in index 6f30cd4..7e5ed56 100644 --- a/python/setup.py.in +++ b/python/setup.py.in @@ -1,8 +1,8 @@ #!/usr/bin/env python3 -""" +''' Setup for SWIG Python bindings for lex-tools -""" +''' from os import path from distutils.core import Extension, setup from distutils.command.build import build @@ -25,18 +25,16 @@ def get_sources(): return sources def get_include_dirs(): - # get rid of '-I' in LTTOOLBOX_CFLAGS and split list from 1, to remove extra element '' - # Strip extra space at end - dirs = '@LTTOOLBOX_CFLAGS@'.split('-I')[1:] - dirs += '@LIBXML_LIBS@'.split('-I')[1:] - dirs = [x.strip() for x in dirs] + # Remove '-I' from Flags, as python add '-I' on its own + dirs = '@LTTOOLBOX_CFLAGS@'.replace('-I', '').split() + dirs += '@LIBXML_LIBS@'.replace('-I', '').split() return dirs + ['..'] lextools_module = Extension( name='_lextools', sources=get_sources(), - swig_opts = ["-c++", "-I..", "-Wall"], + swig_opts=['-c++', '-I..', '-Wall']+'@LTTOOLBOX_CFLAGS@'.split(), include_dirs=get_include_dirs(), library_dirs=['/usr/include/libxml2', '/usr/local/lib'], extra_compile_args='@CXXFLAGS@'.split(), @@ -47,7 +45,7 @@ setup( name='@PACKAGE@', version='@PACKAGE_VERSION@', description='SWIG interface to @PACKAGE_NAME@', - long_description="SWIG interface to @PACKAGE_NAME@ for use in apertium-python", + long_description='SWIG interface to @PACKAGE_NAME@ for use in apertium-python', # TODO: author, maintainer, url author_email='@PACKAGE_BUGREPORT@', license='GPL-3.0+',