[Python-Dev] Static builds on Windows (original) (raw)

"Martin v. Löwis" martin at v.loewis.de
Thu Jul 29 22:12:39 CEST 2004


Thomas Heller wrote:

I'm lost in these symbols. It seems, the DLEXPORT symbol is already deprecated, and public functions should be, and are, declared PyAPIFUNC.

That might well be. My reference to DL_EXPORT was from memory, and I was too lazy to look up the current macro usage. Looking again.

OTOH, the only way to define PyAPIFUNC as _declspec(dllexport) is to define PyENABLESHARED and PyBUILDCORE. And isn't PyENABLESHARED mutually exclusive with PyNOENABLESHARED?

Right. Why again did you want to define Py_NO_ENABLE_SHARED? I would think that you can define it and still build a static library.

Which makes the exe slightly larger, because of the import table section. I have yet to figure out if extensions can link to these functions - normally they expect the functions in the pythonxy.dll module, and not in the (say) pythonstatic.exe.

Yes. You will need to provide an import library for the final executable, and you need to call this import library python24.lib. Then, extensions should pick it up automatically through the #pragma comment.

Existing binary extensions are not affected - although it might be possible to provide a stub python24.dll which reexports all symbols from .exe. This would be needed only if extension modules are needed.

If you want to disable dynamic loading at run-time, you could offer a patch that allows to disable dynamic loading - either at the C API or even exposed to Python. One implementation of this function could garble _PyImport_Filetab, replacing certain entries with SEARCH_ERROR, e.g. through

PyImport_DisableExtension(".pyd");

Re-enabling a disabled extension is probably not needed.

Regards, Martin



More information about the Python-Dev mailing list