Skip to content Skip to sidebar Skip to footer

Why Cython Compiler Generates A So With Suffix 'cpython-35m-x86_64-linux-gnu.so'

#setup.py from distutils.core import setup from distutils.extension import Extension from Cython.Distutils import build_ext setup( cmdclass = {'build_ext': build_ext},

Solution 1:

A full description is available in PEP 3149. In short: this is a change that applies from Python 3.2 onwards. A version identifier is deliberately added to the filename; filenames with this version identifier are used in preference to those without (but a plain .so or .pyd file without the version identifier will be used if no other option is available to import).

There are two main advantages to adding information to the .so or .pyd file about what version of Python it was compiled against:

  1. It is possible to have .so/.pyd files compatible with multiple versions of Python all compiled to the same directory, making it easier to use or distribute libraries for multiple versions of Python.
  2. It protects you from accidentally importing a module compiled for the wrong version of Python. This is a good thing, since the ABI isn't 100% compatible between Python versions (but is likely to be mostly compatible, which will give you occasional and confusing bugs)

The change to the file name affects all compiled Python modules, not just Cython.

This question describes how to change the identifier that's added - there is rarely a good reason for doing so, however.

Post a Comment for "Why Cython Compiler Generates A So With Suffix 'cpython-35m-x86_64-linux-gnu.so'"