SWIG generates two wrapping layers for Python module: the C wrapper code and Python wrapper code. And, as I understand, both are agnostic to the specific subversion of Python 3.x (3.1-3.6 currently).
However, when compiling the code, I have to include the headers of specific 3.x version of Python, which includes the specific library version in PyConfig.h
, e.g. 3.4: pragma comment(lib,"python34.lib")
- which results in the Python package that has to find and load python34.dll
in the runtime, and the loading will fail with any other version.
But all 3.x versions are compatible and simple editing of the produced .pyd
binary - replacing the python34.dll
with say python36.dll
makes the final module to work with Python 3.6 just fine.
Is there any way to create a Python 3.x package with SWIG that would be able to search and find any available 3.x version installed on the system?
Py_LIMITED_API
and then it will link to python3.lib rather than the specific version. Check the Python.h header – Digestible