467,077 Members | 943 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,077 developers. It's quick & easy.

Help with C extensions under VC6 / WinXP and Python 2.4

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

Jul 18 '05 #1
  • viewed: 1603
Share:
7 Replies
On Wed, 16 Feb 2005 20:57:18 -0500, Scott
<sc**********@CS.Princeton.EDU> wrote:
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
Jul 18 '05 #2


John Machin wrote:
On Wed, 16 Feb 2005 20:57:18 -0500, Scott
<sc**********@CS.Princeton.EDU> wrote:

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.

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/


Thanks for the pointer. This looks promising.

Scott
Jul 18 '05 #3
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)?

Jul 18 '05 #4
"Scott" <sc**********@CS.Princeton.EDU> wrote:
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>

Jul 18 '05 #5
Simon John wrote:
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>

Jul 18 '05 #6
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.
--
------------------------------------------------------------------------
Miki Tebeka <mi*********@zoran.com>
http://tebeka.bizhat.com
The only difference between children and adults is the price of the toys
Jul 18 '05 #7
Scott wrote:
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
Jul 18 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Dennis Lee | last post: by
reply views Thread by Unknown User | last post: by
1 post views Thread by webguynow | last post: by
reply views Thread by Jose Vicente Nunez Z | last post: by
1 post views Thread by George Carman | last post: by
3 posts views Thread by Godzilla | last post: by
1 post views Thread by Rahul | last post: by
37 posts views Thread by John Salerno | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.