Skip to content

Commit

Permalink
3. disutils->setuptools
Browse files Browse the repository at this point in the history
  • Loading branch information
singh-lokendra committed Jun 4, 2019
1 parent 691d9f9 commit 65457df
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
4 changes: 2 additions & 2 deletions python/Makefile.am
Expand Up @@ -3,6 +3,6 @@ SWIG_SOURCES = analysis.i
# TODO: Check libdivvun to remove call to all
all: analysis_wrap.cpp

analysis_wrap.cpp: $(SWIG_SOURCES)
analysis_wrap.cpp: $(SWIG_SOURCES) setup.py
$(SWIG) $(AX_SWIG_PYTHON_OPT) -I$(top_srcdir) -o $@ $<
$(PYTHON) setup.py build
$(PYTHON) setup.py install
33 changes: 23 additions & 10 deletions python/setup.py.in
Expand Up @@ -4,7 +4,17 @@
Setup for SWIG Python bindings for lttoolbox
"""

from distutils.core import setup, Extension
from setuptools import Extension, setup
from distutils.command.build import build


class CustomBuild(build):
sub_commands = [
('build_ext', build.has_ext_modules),
('build_py', build.has_pure_modules),
('build_clib', build.has_c_libraries),
('build_scripts', build.has_scripts),
]


def getenv_list(var_name):
Expand All @@ -15,32 +25,35 @@ def getenv_list(var_name):
else:
return []


def get_sources():
from os import path
sources = ['analysis_wrap.cpp']
cc = '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.split()])
sources.extend([path.join(rel_path, f) for f in cc_sources.split()])
return sources


analysis_module = Extension(
'_analysis',
name='_analysis',
sources=get_sources(),
include_dirs=['@top_srcdir@', '/usr/include/libxml2'],
library_dirs=['/usr/include/libxml2'],
extra_compile_args=getenv_list('CPPFLAGS') + getenv_list('CXXFLAGS'),
extra_link_args=getenv_list('LDFLAGS') + ['-lxml2'])

extra_link_args=getenv_list('LDFLAGS') + ['-lxml2']
)

setup(name='python-@PACKAGE@',
setup(
name='python-@PACKAGE@',
version='@PACKAGE_VERSION@',
description='SWIG interface to @PACKAGE_NAME@',
long_description="SWIG interface to @PACKAGE_NAME@ for use in apertium-python",
# TODO: author, maintainer, url
author_email='@PACKAGE_BUGREPORT@',
license='GPL-3.0+',
maintainer_email='@PACKAGE_BUGREPORT@',
py_modules=['analysis'],
ext_modules=[analysis_module])
cmdclass={'build': CustomBuild},
ext_modules=[analysis_module],
)

0 comments on commit 65457df

Please sign in to comment.