Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion swig/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

EXTRA_DIST = \
python/prepare.sh \
python/setup.py.in \
python/setup.py \
python/export_wrap.cpp \
python/simstring.py \
python/sample.py \
Expand Down
8 changes: 4 additions & 4 deletions swig/python/prepare.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/bin/sh
#!/bin/sh -xe
# $Id:$

ln -s ../export.cpp
ln -s ../export.h
ln -s ../export.i
ln -sf ../export.cpp
ln -sf ../export.h
ln -sf ../export.i

if [ "$1" = "--swig" ];
then
Expand Down
23 changes: 20 additions & 3 deletions swig/python/setup.py.in → swig/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
"""

import sys
import os
import os.path
import re

def get_rootdir():
return os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))
Expand All @@ -15,10 +17,24 @@ def get_includedir():
def get_swigdir():
return os.path.join(get_rootdir(), 'swig')

def get_version():
with open(os.path.join(get_rootdir(), 'configure.in')) as f:
for line in f:
m = re.search(r'AM_INIT_AUTOMAKE\([^,]*,\s*([^)]+)\)', line)
if m:
return m.group(1)

import os; os.environ['CC'] = 'g++'; os.environ['CXX'] = 'g++';
os.environ['CPP'] = 'g++'; os.environ['LDSHARED'] = 'g++'

from distutils.core import setup, Extension
from distutils.command import build_ext as build_ext_module

class build_ext(build_ext_module.build_ext):
def run(self):
prepare_script = os.path.abspath(os.path.join(os.path.dirname(__file__), 'prepare.sh'))
assert os.system(prepare_script + ' --swig') == 0
build_ext_module.build_ext.run(self)

simstring_module = Extension(
'_simstring',
Expand All @@ -27,16 +43,17 @@ def get_swigdir():
'export_wrap.cpp',
],
include_dirs=[get_includedir(),],
extra_link_args=['-shared', '-liconv', '-lpython'],
extra_link_args=['-shared'],
language='c++',
)

setup(
name = '@PACKAGE@',
version = '@VERSION@',
name = 'simstring',
version = get_version(),
author = 'Naoaki Okazaki',
description = """SimString Python module""",
ext_modules = [simstring_module],
py_modules = ["simstring"],
cmdclass = {'build_ext': build_ext,},
)