Debugging Python extensions

G

Gus Tabares

Hello all,

I'm writing some Python extensions in C under Windows using Visual
Studio .NET 2003. I want to be able to debug my extensions using .NET.
I'm not very clear on the exact process of doing this.

So far I have compiled a debug version of the 'pythoncore' project
that is located in the Python sources. This has produced the
python23_d.dll which I will use to link with my pyd.

I have a few questions after this step:

1. Do I need to compile my own version of Python2.3 to debug my pyd?
2. Do I have to name my debug pyd as filename_d.pyd?
3. Does the init function need to be named initfilename_d?

I understand that .NET 2003 is not "supported" (I believe only VS6 is)
but I would think using .NET 2003 would not be much different aside
from converting the projects to the new format.

Thanks,
Gus
 
M

Mike Rovner

Gus said:
So far I have compiled a debug version of the 'pythoncore' project
that is located in the Python sources. This has produced the
python23_d.dll which I will use to link with my pyd.

You don't have to.
I have a few questions after this step:

1. Do I need to compile my own version of Python2.3 to debug my pyd?
no

2. Do I have to name my debug pyd as filename_d.pyd?
no

3. Does the init function need to be named initfilename_d?
no

I understand that .NET 2003 is not "supported" (I believe only VS6 is)

no. support code is already in cvs
but I would think using .NET 2003 would not be much different aside
from converting the projects to the new format.

It's straightforward:

1. use stock python.exe
2. compile (debug version) of your extension module as DLL project and name
output mymodule.dll (make sure you use initmymodule() inside.
3. in project properties set
debugging /command > <full path to python.exe> i.e.
c:\python23\python.exe
debugging /command arguments > <simple test script or even -c "import
mymodule">
also usefull:
debugging /working directory > <full path to your script>

Make sure you have mymodule.dll in the same place as test script and you are
all set.
Put breakpoints, hit run, do as usual in VS.NET.

HTH,
Mike
 
V

vincent wehren

| Hello all,
|
| I'm writing some Python extensions in C under Windows using Visual
| Studio .NET 2003. I want to be able to debug my extensions using .NET.
| I'm not very clear on the exact process of doing this.
|
| So far I have compiled a debug version of the 'pythoncore' project
| that is located in the Python sources. This has produced the
| python23_d.dll which I will use to link with my pyd.
|
| I have a few questions after this step:

| 1. Do I need to compile my own version of Python2.3 to debug my pyd?

Yes, you need python23_d.dll (which you say you already have, as well as
python_d.exe


| 2. Do I have to name my debug pyd as filename_d.pyd?

Yes.

| 3. Does the init function need to be named initfilename_d?

No.

|
| I understand that .NET 2003 is not "supported" (I believe only VS6 is)
| but I would think using .NET 2003 would not be much different aside
| from converting the projects to the new format.

I think it was Martin v. Löwis who created the VC++ 7.1 projects that live
in the PCBuild directory for the current development version - you can
download it off
http://cvs.perl.org/snapshots/python/python/python-latest.tar.gz
Check the readme.txt in that same directory for further details...

HTH,
Vincent Wehren


| Thanks,
| Gus
 

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

Forum statistics

Threads
473,767
Messages
2,569,571
Members
45,045
Latest member
DRCM

Latest Threads

Top