Home > Net >  How do tell "swig -python -py3 myswig.i" not to include annotations
How do tell "swig -python -py3 myswig.i" not to include annotations

Time:03-05

I need to use SWIG to support both Python 2.7 and Python 3.10. [Yes, I know that Python 2.7 is dead, and we're doing our best to migrate users away from it as quickly as we can.]

I generate my module via setuptools.setup with a Swig extension. I can run the setup using both Python2 and Python3. The setuptools program creates a separate shareable library for the Python2 and Python3 runs. However both runs generate a myswig.py file in the same location.

It turns out that the Py2 and Py3 generated files are identical, except that the Py3 generated file contains annotations for the functions and the Py2 doesn't. Python3 can read the Python2 generated file and works just fine. Python2 cannot read the Python3 generated file.

I've tried both

  • Related