Skip to content

Commit

Permalink
Implemented changes suggested
Browse files Browse the repository at this point in the history
.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 #
  • Loading branch information
singh-lokendra committed Jun 5, 2019
1 parent b22c781 commit bde6eb2
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 32 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions configure.ac
Expand Up @@ -140,11 +140,9 @@ static_assert(!is_same<size_t,uint32_t>::value, "size_t == uint32_t");
static_assert(!is_same<size_t,uint64_t>::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
Expand Down
3 changes: 1 addition & 2 deletions 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 $@ $<
Expand Down
28 changes: 10 additions & 18 deletions python/analysis.i
Expand Up @@ -7,25 +7,18 @@
#include <lttoolbox/my_stdio.h>
#include <lttoolbox/lt_locale.h>

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();
Expand All @@ -42,17 +35,16 @@ FST::init_analysis(char *automorf_path, char *input_path, char *output_path)
%}


#include <lttoolbox/fst_processor.h>
#include <lttoolbox/lttoolbox_config.h>
#include <lttoolbox/my_stdio.h>
#include <lttoolbox/lt_locale.h>
%include <lttoolbox/fst_processor.h>
%include <lttoolbox/lttoolbox_config.h>
%include <lttoolbox/my_stdio.h>
%include <lttoolbox/lt_locale.h>

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);
};
12 changes: 6 additions & 6 deletions 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

Expand All @@ -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(
Expand All @@ -46,4 +45,5 @@ setup(
maintainer_email='@PACKAGE_BUGREPORT@',
cmdclass={'build': CustomBuild},
ext_modules=[analysis_module],
py_modules=['analysis'],
)

0 comments on commit bde6eb2

Please sign in to comment.