Yurttas/PL/SL/python/docs/core-python-programming/doc/20/ext/win-cookbook.html

Revision as of 19:38, 7 November 2013 by MassBot1 (talk | contribs) (Created page with "<div class="navigation"> {| width="100%" cellspacing="2" align="center" | yurttas/PL/SL/python/docs/core-python-programming/doc/20/ext/building-on-windows.html|[[Image:...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


3.1 A Cookbook Approach

This section provides a recipe for building a Python extension on Windows.

Grab the binary installer from http://www.python.org/  ] and install Python. The binary installer has all of the required header files except for config.h.

Get the source distribution and extract it into a convenient location. Copy the config.h from the PC/ directory into the include/ directory created by the installer.

Create a Setup file for your extension module, as described in chapter 2.

Get David Ascher's compile.py script from http://starship.python.net/crew/da/compile/  ]. Run the script to create Microsoft Visual C++ project files.

Open the DSW file in Visual C++ and select Build.

If your module creates a new type, you may have trouble with this line:

    PyObject_HEAD_INIT(&PyType_Type)

Change it to:

    PyObject_HEAD_INIT(NULL)

and add the following to the module initialization function:

    MyObject_Type.ob_type = &PyType_Type;

Refer to section 3 of the Python FAQ (http://www.python.org/doc/FAQ.html  ]) for details on why you must do this.


See About this document... for information on suggesting changes.