Info Node: (python2.1-ext.info)A Cookbook Approach
(python2.1-ext.info)A Cookbook Approach
A Cookbook Approach
===================
This manual section was written by Neil Schemenauer
<neil_schemenauer@transcanada.com>.
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 Note:Building C and C++ Extensions on UNIX.
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 for details on why you must do this.