Help with C extensions under VC6 / WinXP and Python 2.4

S

Scott

I've installed Python 2.4 under WinXP and am attempting to
create an extension module using the steps outlined here:
http://python.org/doc/2.4/ext/win-cookbook.html

I'm specifically trying to perform step 6. Creating a brand
new project using VC6.

The trouble I have is that there are no PC or PCbuild
subdirectories in C:\Python24. Where do I find these?

Ultimately, what I want to do is interface some Python
code with a DLL that controls an A/D board. I expect
I'll need to write an extension module to act as a shim
between this DLL and the Python code.

Scott
 
J

John Machin

I've installed Python 2.4 under WinXP and am attempting to
create an extension module using the steps outlined here:
http://python.org/doc/2.4/ext/win-cookbook.html

I'm specifically trying to perform step 6. Creating a brand
new project using VC6.

The trouble I have is that there are no PC or PCbuild
subdirectories in C:\Python24. Where do I find these?

As the quoted URL says (2nd para):
"""
To build extensions using these instructions, you need to have a copy
of the Python sources of the same version as your installed Python.
[snip]
The example files described here are distributed with the Python
sources in the PC\ example_nt\ directory
"""

i.e. you have to download a copy of the Python source distribution.
Ultimately, what I want to do is interface some Python
code with a DLL that controls an A/D board. I expect
I'll need to write an extension module to act as a shim
between this DLL and the Python code.

Possibly not; check out the ctypes module --
http://starship.python.net/crew/theller/ctypes/

but *do* please read the docs before posting :)

HTH,
John
 
S

Scott

John said:
> On Wed, 16 Feb 2005 20:57:18 -0500, Scott
>
>
>>I've installed Python 2.4 under WinXP and am attempting to
>>create an extension module using the steps outlined here:
>>http://python.org/doc/2.4/ext/win-cookbook.html
>>
>>I'm specifically trying to perform step 6. Creating a brand
>>new project using VC6.
>>
>>The trouble I have is that there are no PC or PCbuild
>>subdirectories in C:\Python24. Where do I find these?
>
>
> As the quoted URL says (2nd para):
> """
> To build extensions using these instructions, you need to have a copy
> of the Python sources of the same version as your installed Python.
> [snip]
> The example files described here are distributed with the Python
> sources in the PC\ example_nt\ directory
> """
>
> i.e. you have to download a copy of the Python source distribution.

Since I had an include directory, I assumed (incorrectly) that
I already had the sources. Thanks for the reiteration -- it's
what I needed.
>
>
>
>
> Possibly not; check out the ctypes module --
> http://starship.python.net/crew/theller/ctypes/

Thanks for the pointer. This looks promising.

Scott
 
S

Simon John

What's the difference between ctypes, SWIG and SIP?

I've used SWIG to "convert" C source to Python (as I believe SIP
does?), so does ctypes wrap functions from binaries (e.g. DLL's)?
 
F

Fredrik Lundh

Scott said:
The trouble I have is that there are no PC or PCbuild
subdirectories in C:\Python24. Where do I find these?


As the quoted URL says (2nd para):
"""
To build extensions using these instructions, you need to have a copy
of the Python sources of the same version as your installed Python.
[snip]
The example files described here are distributed with the Python
sources in the PC\ example_nt\ directory
"""

i.e. you have to download a copy of the Python source distribution.

Since I had an include directory, I assumed (incorrectly) that
I already had the sources. Thanks for the reiteration -- it's
what I needed.

here's another iteration: the top of that page says:

"There are two approaches to building extension modules on Windows,
just as there are on Unix: use the distutils package to control the
build process, or do things manually. The distutils approach works
well for most extensions; documentation on using distutils to
build and package extension modules is available in "Distributing
Python Modules". This section describes the manual approach to
building Python extensions written in C or C++. "

if you're not 100% sure what you're doing, and why you need to use the
manual approach (you don't), *please* use the distutils solution. here's
a minimal setup script:

from distutils.core import setup, Extension

setup(
name="mymodule",
ext_modules = [Extension("mymodule", ["mymodule.c"])]
)

to build, use "python setup.py build". to build a local copy ("in place"), use
"python setup.py build_ext -i". to build and install, use "python setup.py
install".

no need to download any extra stuff; it just works.

</F>
 
F

Fredrik Lundh

Simon said:
What's the difference between ctypes, SWIG and SIP?

I've used SWIG to "convert" C source to Python (as I believe SIP
does?), so does ctypes wrap functions from binaries (e.g. DLL's)?

ctypes is a "runtime linker". it generates bindings on the fly, at runtime,
and doesn't require a separate compilation step.

</F>
 
M

Miki Tebeka

Hello Simon,
What's the difference between ctypes, SWIG and SIP?
SIG and SIP take C/C++ *sources* and create Python modules. ctypes works
directly with the binary dll.

Bye.
 
?

=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=

Scott said:
I'm specifically trying to perform step 6. Creating a brand
new project using VC6.

The instructions are outdated. Don't use VC6 to build
extension modules for Python 2.4.

Regards,
Martin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top