Why can’t I build python extensions with a different version of Visual Studio?
The short answer: you probably can if you are careful enough to limit your use of Python API calls.
For example, you cannot use PyFile_AsFile, the reason is that C runtime objects like FILE* created in one runtime e.g. msvcrt.dll cannot be used in another, e.g. msvcrt70.dll
In addition, malloc() allocated memory from one runtime cannot be freed from another runtime.
Here’s a rundown:
- Potential Errors Passing CRT Objects Across DLL Boundaries
- Also read PEP 384 – maintaining a stable ABI, where it mentions
In addition, functions expecting FILE* are not part of the ABI, to avoid depending on a specific version of the Microsoft C runtime DLL on Windows.
Interestingly, there are techniques called forwarder DLLs that redirect DLL calls to another version.
- See Exported functions that are really forwarders.
- DLL forwarding in Python (StackOverflow).
More interestingly though is the possibility of using Visual Studio to link against the older runtime directly
About this entry
You’re currently reading “ Why can’t I build python extensions with a different version of Visual Studio? ,” an entry on Chui's Counterpoint
- Published:
- 1.8.13 / 6am
- Category:
- Python
Comments are closed
Comments are currently closed on this entry.