Compiling Python on Windows : how to deal with modules ?

r2d3 david.geldreich at
Tue May 12 07:53:39 EDT 2009

Hi all,

after some investigation, I managed to find how to do this "manually".
I post it here if it could help others...

1) on windows, mostly all the dynamic libraries (time, socket, ...)
are statically linked into python26.dll
2) all the modules are located in lib/ and some .pyd (in fact renamed
dll files) live in PCbuild
3) "PCBuild\python -m compileall lib" will compile all the .py under
lib which then could by zipped into a single

So I will just need to distribute python26.dll and with
my app and set sys.path (using PySys_SetPath) to point to
+ the place where I store the .pyd.

I will solve the "user want to add other module" later using
PYTHONPATH or allowing the user to add python path through our GUI.

Best regards.

On 11 mai, 10:49, r2d3 <david.geldre... at> wrote:
> I am using Python embedded in my application (OSX,Windows) and I need
> to distribute Python as part of my application.
> On OSX, no problem, I got a self contained framework (with dynamic
> library and all the modules).
> On Windows, I manage to compile Python 2.6.2 with PCbuild\build.bat
> and I get python26.dll/python26_d.dll.
> But the readme gives no clue about how to deal with the module
> "compilation"/installation.
> So how do I "compile"/package all the modules that comes with Python
> source distribution on Windows ? To embed it in my distribution, I
> just copy the whole Modules tree (only pyc/pyo/pyd files ?) ? and set
> the right sys.path from my C code (using PySys_SetPath) ?

More information about the Python-list mailing list