Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3de61bc

Browse files
committed
Integrated notes on building extension modules on Windows, by Neil
Schemenauer <[email protected]>. Thanks, Neil!
1 parent f6838c0 commit 3de61bc

1 file changed

Lines changed: 50 additions & 1 deletion

File tree

Doc/ext/ext.tex

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1511,7 +1511,7 @@ \section{Providing a C API for an Extension Module
15111511

15121512

15131513
\chapter{Building C and \Cpp{} Extensions on \UNIX{}
1514-
\label{building-extensions}}
1514+
\label{building-on-unix}}
15151515

15161516
\sectionauthor{Fim Fulton}{[email protected]}
15171517

@@ -1680,6 +1680,55 @@ \section{Distributing your extension modules
16801680
should use \file{Makefile.pre.in} to build their own make file.
16811681

16821682

1683+
\chapter{Building C and \Cpp{} Extensions on Windows
1684+
\label{building-on-unix}}
1685+
1686+
\sectionauthor{Neil Schemenauer}{[email protected]}
1687+
1688+
1689+
This chapter briefly explains how to create a Windows extension module
1690+
for Python using Microsoft Visual \Cpp{}.
1691+
1692+
Grab the binary installer from \url{http://www.python.org/} and
1693+
install Python. The binary installer has all of the required header
1694+
files except for \file{config.h}.
1695+
1696+
Get the source distribution and extract it into a convenient location.
1697+
Copy the \file{config.h} from the \file{PC/} directory into the
1698+
\file{include/} directory created by the installer.
1699+
1700+
Create a \file{Setup} file for your extension module, as described in
1701+
Chapter \ref{building-on-unix}.
1702+
1703+
Get David Ascher's \file{compile.py} script from
1704+
\url{http://starship.skyport.net/~da/compile/}. Run the script to
1705+
create Microsoft Visual \Cpp{} project files.
1706+
1707+
Open the DSW file in V\Cpp{} and select \strong{Build}.
1708+
1709+
If your module creates a new type, you may have trouble with this line:
1710+
1711+
\begin{verbatim}
1712+
PyObject_HEAD_INIT(&PyType_Type)
1713+
\end{verbatim}
1714+
1715+
Change it to:
1716+
1717+
\begin{verbatim}
1718+
PyObject_HEAD_INIT(NULL)
1719+
\end{verbatim}
1720+
1721+
and add the following to the module initialization function:
1722+
1723+
\begin{verbatim}
1724+
MyObject_Type.ob_type = &PyType_Type;
1725+
\end{verbatim}
1726+
1727+
Refer to section 3 of the Python FAQ
1728+
(\url{http://www.python.org/doc/FAQ.html}) for details on why you must
1729+
do this.
1730+
1731+
16831732
\chapter{Embedding Python in Another Application
16841733
\label{embedding}}
16851734

0 commit comments

Comments
 (0)