Skip to content

Compile pip-installable wheel on Ubuntu 20.10 [solved] #27

Description

@fginter

Just in case anyone needs this, this is how I compiled and installed simstring on Ubuntu 20.10. I am sure the pull request #26 is solving the same thing, but I did not notice it until it was too late. So for the record, this "worked for me" (tm)

  1. make sure you have python-dev and swig installed from your package manager
./autogen.sh
./configure
make
cd swig/python
./prepare.sh --swig
pip3 install --upgrade pip setuptools wheel

Now replace setup.py with the version below and then you can:

python3 setup.py bdist_wheel

This gets you a wheel file under dist which you can pip-install as you wish

pip3 install /path/to/simstring/swig/python/dist/simstring.version.whl

Here is a test in python

>>> import simstring
>>> db=simstring.writer("test.db")
>>> db.insert("koira")
>>> db.insert("kissa")
>>> db.insert("autoni")
>>> db.insert("Åbo Akademi")
>>> db.close()
>>> db=simstring.reader("test.db")
>>> db.measure=simstring.cosine
>>> db.threshold=0.5
>>> db.lookup
>>> db.retrieve("Abo akademi")
('Åbo Akademi',)
>>> db.retrieve("auto")
('autoni',)
>>> db.close()

And here is the corrected setup.py:

#!/usr/bin/env python
"""
setup.py file for SWIG example
"""
import sys
import os.path
import setuptools
import sysconfig
def get_rootdir():
    return os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))
def get_includedir():
    return os.path.join(get_rootdir(), 'include')
def get_swigdir():
    return os.path.join(get_rootdir(), 'swig')
import os; os.environ['CC'] = 'g++'; os.environ['CXX'] = 'g++';
os.environ['CPP'] = 'g++'; os.environ['LDSHARED'] = 'g++'
from setuptools import setup, Extension
simstring_module = Extension(
    '_simstring',
    sources = [
        'export.cpp',
        'export_wrap.cpp',
        ],
    include_dirs=[get_includedir(),],
    extra_link_args=['-shared', sysconfig.get_config_var("BLDLIBRARY")],
    language='c++',
    )
setup(
    name = 'simstring',
    version = '1.1',
    author = 'Naoaki Okazaki',
    description = """SimString Python module""",
    ext_modules = [simstring_module],
    py_modules = ["simstring"],
    )

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions