commit bde6eb2de6c1b19ee0e8c943e6da48241068c39c Author: vaydheesh Date: Wed Jun 5 16:08:08 2019 +0000 Implemented changes suggested .travis: changed install: to before_install: added -y flag for ubuntu configure.ac: modified warning message for python version python/Makefile: removed target 'all' instead use BUILT_SOURCES setup.py.in: changed shebang to python3, changed cc_sources type to list analysis.i: inherit FSTProcessor publicly removed FST::validity() renamed init_analysis -> analyze fixed: swig file include, use % instead of # diff --git a/.travis.yml b/.travis.yml index 6aecef4..753e735 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,8 +6,8 @@ os: compiler: - clang - gcc -install: - - if [ $TRAVIS_OS_NAME = linux ]; then sudo apt-get install swig python3-setuptools; else brew install swig; fi +before_install: + - if [ $TRAVIS_OS_NAME = linux ]; then sudo apt-get install -y swig python3-setuptools; else brew install swig; fi script: - ./autogen.sh - ./configure diff --git a/configure.ac b/configure.ac index a6d578f..8c11910 100644 --- a/configure.ac +++ b/configure.ac @@ -140,11 +140,9 @@ static_assert(!is_same::value, "size_t == uint32_t"); static_assert(!is_same::value, "size_t == uint64_t"); ]])], [AC_DEFINE([SIZET_NOT_CSTDINT], [1], [size_t != (uint32_t, uint64_t)])]) -AM_PATH_PYTHON([3.4], [], [AC_MSG_WARN([Can't generate wrapper without Python])]) +AM_PATH_PYTHON([3.4], [], [AC_MSG_WARN([Can't generate SWIG wrapper or run tests without Python])]) -AC_CONFIG_FILES([ - python/setup.py - ]) +AC_CONFIG_FILES([python/setup.py]) AX_PKG_SWIG(3.0.4) AX_SWIG_ENABLE_CXX AX_SWIG_PYTHON diff --git a/python/Makefile.am b/python/Makefile.am index 6b5e1d7..8f3ac9a 100644 --- a/python/Makefile.am +++ b/python/Makefile.am @@ -1,7 +1,6 @@ SWIG_SOURCES = analysis.i -# TODO: Check libdivvun to remove call to all -all: analysis_wrap.cpp +BUILT_SOURCES = analysis_wrap.cpp analysis.py analysis_wrap.cpp: $(SWIG_SOURCES) setup.py $(SWIG) $(AX_SWIG_PYTHON_OPT) -I$(top_srcdir) -o $@ $< diff --git a/python/analysis.i b/python/analysis.i index d295346..98fbf23 100644 --- a/python/analysis.i +++ b/python/analysis.i @@ -7,25 +7,18 @@ #include #include -class FST: private FSTProcessor +class FST: public FSTProcessor { public: /** * Reads from input_path and stores result at output_path */ - void init_analysis(char *automorf_path, char *input_path, char *output_path); - bool validity() const; - + void analyze(char *automorf_path, char *input_path, char *output_path); }; -bool -FST::validity() const -{ - return valid(); -} void -FST::init_analysis(char *automorf_path, char *input_path, char *output_path) +FST::analyze(char *automorf_path, char *input_path, char *output_path) { setDictionaryCaseMode(true); LtLocale::tryToSetLocale(); @@ -42,17 +35,16 @@ FST::init_analysis(char *automorf_path, char *input_path, char *output_path) %} -#include -#include -#include -#include +%include +%include +%include +%include -class FST: private FSTProcessor +class FST: public FSTProcessor { public: /** * Reads from input_path and stores result at output_path */ - void init_analysis(char *automorf_path, char *input_path, char *output_path); - bool validity() const; -}; + void analyze(char *automorf_path, char *input_path, char *output_path); +}; diff --git a/python/setup.py.in b/python/setup.py.in index c267d8c..1902603 100644 --- a/python/setup.py.in +++ b/python/setup.py.in @@ -1,9 +1,9 @@ -#!/usr/bin/python +#!/usr/bin/env python3 """ Setup for SWIG Python bindings for lttoolbox """ - +from os import path from setuptools import Extension, setup from distutils.command.build import build @@ -18,12 +18,11 @@ class CustomBuild(build): def get_sources(): - from os import path sources = ['analysis_wrap.cpp'] - cc_sources = 'alphabet.cc compression.cc fst_processor.cc\ - lt_locale.cc node.cc state.cc trans_exe.cc xml_parse_util.cc' + cc_sources = ['alphabet.cc', 'compression.cc', 'fst_processor.cc', 'lt_locale.cc', + 'node.cc', 'state.cc', 'trans_exe.cc', 'xml_parse_util.cc'] rel_path = '@top_srcdir@/lttoolbox/' - sources.extend([path.join(rel_path, f) for f in cc_sources.split()]) + sources.extend(path.join(rel_path, f) for f in cc_sources) return sources analysis_module = Extension( @@ -46,4 +45,5 @@ setup( maintainer_email='@PACKAGE_BUGREPORT@', cmdclass={'build': CustomBuild}, ext_modules=[analysis_module], + py_modules=['analysis'], )