February 2006
Intermediate to advanced
648 pages
14h 53m
English
Extension modules are usually compiled into shared libraries or DLLs that can be dynamically loaded by the interpreter. The low-level details of this process vary on every machine, but the distutils module in the Python library can be used to simplify the process. To create an extension module using distutils, follow these steps:
1. | Create a file called setup.py that starts with the following code:
# setup.py from distutils.core import setup, Extension |
2. | Next, add some source information about your extension, as follows:
setup(name="spam", version="1.0",
ext_modules=[Extension("spam", ["spam.c", "spamwrapper.c"])]) |
3. | Now, to build your extension, type the following:
python setup.py build |
At this point, a shared ...