Help with C extensions under VC6 / WinXP and Python 2.4

Discussion in 'Python' started by Scott, Feb 17, 2005.

  1. Scott

    Scott Guest

    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
     
    Scott, Feb 17, 2005
    #1
    1. Advertising

  2. Scott

    John Machin Guest

    On Wed, 16 Feb 2005 20:57:18 -0500, Scott
    <> 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
     
    John Machin, Feb 17, 2005
    #2
    1. Advertising

  3. Scott

    Scott Guest

    John Machin wrote:
    > On Wed, 16 Feb 2005 20:57:18 -0500, Scott
    > <> 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
     
    Scott, Feb 17, 2005
    #3
  4. Scott

    Simon John Guest

    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)?
     
    Simon John, Feb 17, 2005
    #4
  5. "Scott" <> 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>
     
    Fredrik Lundh, Feb 17, 2005
    #5
  6. 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>
     
    Fredrik Lundh, Feb 17, 2005
    #6
  7. Scott

    Miki Tebeka Guest

    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 <>
    http://tebeka.bizhat.com
    The only difference between children and adults is the price of the toys
     
    Miki Tebeka, Feb 17, 2005
    #7
  8. 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
     
    =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=, Feb 17, 2005
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Greg Roberts

    Using splint on C files under MS VC6

    Greg Roberts, Jan 23, 2004, in forum: C Programming
    Replies:
    0
    Views:
    462
    Greg Roberts
    Jan 23, 2004
  2. Franz Steinhäusler

    Change between Python 2.3 and 2.4 under WinXP

    Franz Steinhäusler, Mar 31, 2005, in forum: Python
    Replies:
    14
    Views:
    586
    =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=
    Apr 5, 2005
  3. =?iso-8859-15?q?Berthold_H=F6llmann?=

    Python 2.4 under WinXP, free VC71 toolkit and VC6 libraries

    =?iso-8859-15?q?Berthold_H=F6llmann?=, Sep 27, 2005, in forum: Python
    Replies:
    6
    Views:
    334
    Fredrik Lundh
    Sep 28, 2005
  4. Guest
    Replies:
    1
    Views:
    252
    Peter Notebaert
    Nov 5, 2005
  5. stef
    Replies:
    2
    Views:
    304
Loading...

Share This Page