473,386 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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
7 1770
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Dennis Lee | last post by:
My OS is Winxp . My web server is apache 2 which is installed as a NT service . My php version is 4.32 , and I extracted it into "c:\php" . I run php as a apache module . I want to load...
0
by: Unknown User | last post by:
Yesterday I did a fresh install of Apache 2, PHP5 as CGI and MySQL 4 on WinXP. Apache and PHP work fine, MySQL works fine in the command line, but I can't have PHP to find the MySQL extensions. ...
1
by: webguynow | last post by:
I'm hoping someone will give me the latest info here about PHP policy to enable extensions. I've installed PHP5 in C:\PHP Meaningful excerpts: from php.ini ; Directory in which the...
0
by: Jose Vicente Nunez Z | last post by:
Greetings, I wrote a couple of custom dummy extensions in Python (one a pure Python and the other a C) and i managed to compile and install them without a problem: $ make python2 setup.py...
2
by: Eric Woudenberg | last post by:
I just installed a Python 2.3.4 Windows binary on a friend's WinXP machine (because the latest Cygwin-provided Python 2.3 build leaves out the winsound module for some reason). When I try and...
1
by: George Carman | last post by:
Please excuse the following mailing, I do not have access to a news server and cannot post to comp.lang.python. I recently installed Python 2.3.4 on WinXP. Command line interpreter works fine...
3
by: Godzilla | last post by:
Has anyone install Python on Windows XP Embedded? We wish to evaluate the possible solution of installing Python with WinXPE on a PC/104 plus module. Thank you.
1
by: Rahul | last post by:
Hi Everybody I have some problem in my script. please help me. This is script file. I have one *.inq file. I want run this script in XML files. But this script errors shows . If u want i am...
37
by: John Salerno | last post by:
I contacted my domain host about how Python is implemented on their server, and got this response: ------------------- Hello John, Please be informed that the implementation of python in our...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.