@@ -2,9 +2,9 @@ Example Python extension for Windows NT
22=======================================
33
44This directory contains everything you need to build a Python
5- extension module using Microsoft VC++ 4.x ("Developer Studio"), except
6- for the Python distribution. It has been tested most recently with
7- version 4.2. (Yes, it has been tested with the latest Python 1.5a3.)
5+ extension module using Microsoft VC++ ("Developer Studio") version 4.x
6+ or 5.x, except for the Python distribution. It has been tested with
7+ VC++ 4.2 on Python 1.5a3, and with VC++ 5.0 on Python 1.5b2.
88
99The "example_nt" subdirectory should be an immediate subdirectory of
1010the Python source directory -- a direct sibling of Include and PC, in
@@ -14,22 +14,30 @@ level or you will regret it! (This is done to keep all the PC
1414specific files inside the PC subdirectory of the distribution, where
1515they belong.)
1616
17- It is also assumed that the build results of Python are in the
18- directory ..\vc40. In particular, the python15.lib file is referred
19- to as "..\vc40\python15.lib". If you have problems with this file,
20- the best thing to do is to delete it from the project and add it
21- again.
17+ When using the VC++ 4.x project (makefile), it is assumed that the
18+ build results of Python are in the directory ..\vc40. In particular,
19+ the python15.lib file is referred to as "..\vc40\python15.lib". If
20+ you have problems with this file, the best thing to do is to delete it
21+ from the project and add it again.
2222
23- In order to use the example project from Developer Studio, use the
24- "File->Open Workspace..." dialog (*not* the "File->Open..." dialog!).
25- Change the pattern to "*.mak" and select the file "example.mak". Now
26- choose "File->Save All" and the othe project files will be created.
23+ When using the VC++ 5.x project (workspace), the build results of
24+ Python are assumed to be in ..\PCbuild. Since the provided VC++ 5.x
25+ project and workspace files have a different structure (to support
26+ separate "release" and "debug" builds), the example project and
27+ workspace match this structure.
28+
29+ In order to use the example project from VC++ 4.x, use the "File->Open
30+ Workspace..." dialog (*not* the "File->Open..." dialog!). Change the
31+ pattern to "*.mak" and select the file "example.mak". Now choose
32+ "File->Save All" and the othe project files will be created.
33+
34+ From VC+ 5.x, do the same except don't change the pattern, and select
35+ the example.dsw workspace file.
2736
2837In order to check that everything is set up right, try building:
2938choose "Build->Build example.dll". This creates all intermediate and
3039result files in a subdirectory which is called either Debug or Release
31- depending on which configuration you have chosen (as distributed,
32- Debug is selected as the default configuration).
40+ depending on which configuration you have chosen.
3341
3442Once the build has succeeded, test the resulting DLL. In a DOS
3543command window, chdir to that directory. You should now be able to
@@ -42,6 +50,14 @@ Python prompt):
4250 Hello, world
4351 >>>
4452
53+ When using VC++ 5.x, issue these commands:
54+
55+ C> ..\..\PCbuild\Release\python.exe
56+ >>> import example
57+ >>> example.foo()
58+ Hello, world
59+ >>>
60+
4561
4662Creating the project
4763--------------------
@@ -66,14 +82,18 @@ spam\spam.mak. Do a global edit on spam.mak, replacing all
6682occurrences of the string "example" by "spam", and all occurrences of
6783"DEP_CPP_EXAMP" by something like "DEP_CPP_SPAM". You can now use
6884this makefile to create a project file by opening it as a workspace
69- (you have to change the pattern to *.mak first).
85+ (you have to change the pattern to *.mak first). (When using VC++
86+ 5.x, you can clone example.dsp and example.dsw in a similar way.)
7087
71882) Create a brand new project; instructions are below.
7289
7390In both cases, copy example_nt\example.def to spam\spam.def, and edit
7491spam\spam.def so its second line contains the string "initspam". If
7592you created a new project yourself, add the file spam.def to the
76- project now.
93+ project now. (This is an annoying little file with only two lines.
94+ An alternative approach is to forget about the .def file, and add the
95+ option "/export:initspam" somewhere to the Link settings, by manually
96+ editing the "Project Options" box).
7797
7898You are now all set to build your extension, unless it requires other
7999external libraries, include files, etc. See Python's Extending and
@@ -83,8 +103,9 @@ Embedding manual for instructions on how to write an extension.
83103Creating a brand new project
84104----------------------------
85105
86- If you don't feel comfortable with editing Makefiles, you can create a
87- brand new project from scratch easily.
106+ If you don't feel comfortable with editing Makefiles or project and
107+ workspace files, you can create a brand new project from scratch
108+ easily.
88109
89110Use the "File->New..." dialog to create a new Project Workspace.
90111Select Dynamic-Link Library, enter the name ("spam"), and make sure
@@ -102,7 +123,16 @@ box labeled "Addditional include directories:"
102123
103124 ..\Include,..\PC
104125
105- You must also change the run-time library. This must be done
126+ Next, for both configurations, select the "Link" tab, choose the
127+ "General" category, and add "python15.lib" to the end of the
128+ "Object/library modules" box.
129+
130+ Then, separately for the Release and Debug configurations, choose the
131+ "Input" category in the Link tab, and enter "..\PCbuild\Release" or
132+ "..\PCbuild\Debug", respectively, in the "Additional library path"
133+ box.
134+
135+ Finally, you must change the run-time library. This must also be done
106136separately for the Release and Debug configurations. Choose the "Code
107137Generation" category in the C/C++ tab. In the box labeled "Use
108138run-time library", choose "Multithreaded DLL" for the Release
@@ -114,5 +144,5 @@ previous section.
114144
115145Now chose the "Insert->Files into Project..." dialog. Set the pattern
116146to *.* and select both spam.c and spam.def and click OK. (Inserting
117- them one by one is fine too.) Using the same dialog, choose the file
118- ..\vc40\python15.lib and insert it into the project.
147+ them one by one is fine too.)
148+
0 commit comments