s-yata / marisa-trie

MARISA: Matching Algorithm with Recursively Implemented StorAge
Other
506 stars 89 forks source link

Python binding no longer compatible with python 3.12 and later #55

Open hosiet opened 7 months ago

hosiet commented 7 months ago

https://github.com/s-yata/marisa-trie/blob/006020c1df76d0d7dc6118dacc22da64da2e35c4/bindings/python/marisa.py#L12

The current python binding includes include imp instruction, which will raise error with Python 3.12 or later because the imp module has been removed with Python 3.12.

Downstream bug report: https://bugs.debian.org/1061809

When trying to regenerate the python binding with swig 4.2, the following warnings will appear:

-> % make swig-python          
swig -Wall -c++ -python -outdir python marisa-swig.i
marisa-swig.h:55: Warning 321: 'str' conflicts with a built-in name in python
marisa-swig.h:56: Warning 321: 'id' conflicts with a built-in name in python
marisa-swig.h:69: Warning 321: 'str' conflicts with a built-in name in python
marisa-swig.h:70: Warning 321: 'id' conflicts with a built-in name in python
mv marisa-swig_wrap.cxx python
cp marisa-swig.cxx marisa-swig.h python

Please revise the Python binding and fix the warnings accordingly. Thanks!

juno-rmks commented 3 weeks ago

Unofficially, I have created bindings that can be built with Python 3.10 and later. The source code is derived from the original, and I have set it up for package management via pip and for building with Python 3.10 and later.

https://github.com/juno-rmks/marisa-bindings

The README mentions that it can be installed from PyPI, but since this is an alpha version, it currently only supports installation from GitHub.

% pip install git+https://github.com/juno-rmks/marisa-bindings.git

I have confirmed that the native libraries can be compiled correctly on macOS (Apple Silicon) and Windows (x86_64), but I have not tested on other operating systems or architectures, including Linux. If anyone has time to try it out, I would appreciate your feedback.

If everything works well, I will upgrade to version 1.0.0 and upload it to PyPI.

The name "marisa-trie" is already in use, and using "marisa-swig" would imply reliance solely on SWIG in the future, so I chose the name "marisa-bindings."