Update of /cvsroot/pywin32/pywin32/win32/Demos/c_extension
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9477/c_extension
Added Files:
README.txt setup.py win32_extension.cpp
Log Message:
Sample extension that uses pywintypes
--- NEW FILE: win32_extension.cpp ---
// Note: this sample does nothing useful other than to show you how
// your own Python extension can link with and use the functions from
// pywintypesxx.dll
#include "Python.h"
#include "PyWinTypes.h"
static struct PyMethodDef win32extension_functions[] = {
0
};
extern "C" __declspec(dllexport)
void initwin32_extension(void)
{
// Initialize PyWin32 globals (such as error objects etc)
PyWinGlobals_Ensure();
PyObject *module;
module = Py_InitModule("win32_extension", win32extension_functions);
if (!module)
return;
}
--- NEW FILE: setup.py ---
# A sample distutils script to show to build your own
# extension module which extends pywintypes or pythoncom.
#
# Use 'python setup.py build' to build this extension.
import os
from distutils.core import setup, Extension
from distutils.sysconfig import get_python_lib
sources = ["win32_extension.cpp"]
# Specify the directory where the PyWin32 .h and .lib files are installed.
# If you are doing a win32com extension, you will also need to add
# win32com\Include and win32com\Libs.
ext = Extension("win32_extension", sources,
include_dirs = [os.path.join(get_python_lib(), "win32", "Include")],
library_dirs = [os.path.join(get_python_lib(), "win32", "Libs")],
)
setup(
name="win32 extension sample",
version="0.1",
ext_modules=[ext],
)
--- NEW FILE: README.txt ---
This directory contains a sample Python extension module which
includes PyWinTypes.h and links against PyWinTypesXX.lib The same technique
can be used to include and extend pythoncom.
The sample does nothing useful other than to show how to compile and link
such an extension using a standard pywin32 installation.
|