Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Help with C extensions under VC6 / WinXP and Python 2.4

Reply
Thread Tools

Help with C extensions under VC6 / WinXP and Python 2.4

 
 
Scott
Guest
Posts: n/a
 
      02-17-2005
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

 
Reply With Quote
 
 
 
 
John Machin
Guest
Posts: n/a
 
      02-17-2005
On Wed, 16 Feb 2005 20:57:18 -0500, Scott
<(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
 
Scott
Guest
Posts: n/a
 
      02-17-2005


John Machin wrote:
> On Wed, 16 Feb 2005 20:57:18 -0500, Scott
> <(E-Mail Removed)> 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
 
Reply With Quote
 
Simon John
Guest
Posts: n/a
 
      02-17-2005
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)?

 
Reply With Quote
 
Fredrik Lundh
Guest
Posts: n/a
 
      02-17-2005
"Scott" <(E-Mail Removed)> 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>



 
Reply With Quote
 
Fredrik Lundh
Guest
Posts: n/a
 
      02-17-2005
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>



 
Reply With Quote
 
Miki Tebeka
Guest
Posts: n/a
 
      02-17-2005
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 <(E-Mail Removed)>
http://tebeka.bizhat.com
The only difference between children and adults is the price of the toys
 
Reply With Quote
 
=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=
Guest
Posts: n/a
 
      02-17-2005
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
A router running under WinXP runs under Windows Vista too? Peter Wagner Wireless Networking 12 02-04-2008 11:02 PM
how to compile c-extensions under WinXP? Python 1 11-05-2005 03:46 PM
Python 2.4 under WinXP, free VC71 toolkit and VC6 libraries =?iso-8859-15?q?Berthold_H=F6llmann?= Python 6 09-28-2005 07:41 AM
Using splint on C files under MS VC6 Greg Roberts C Programming 0 01-23-2004 12:08 PM
Help!! About MySQL and VC6 Forecast C++ 0 12-31-2003 09:16 AM



Advertisments