New instructions, take VC++ 5.x into account.

This commit is contained in:
Guido van Rossum 1997-12-11 04:01:25 +00:00
parent 936c6de5d3
commit 55b8b03dfb
1 changed files with 51 additions and 21 deletions

View File

@ -2,9 +2,9 @@ Example Python extension for Windows NT
=======================================
This directory contains everything you need to build a Python
extension module using Microsoft VC++ 4.x ("Developer Studio"), except
for the Python distribution. It has been tested most recently with
version 4.2. (Yes, it has been tested with the latest Python 1.5a3.)
extension module using Microsoft VC++ ("Developer Studio") version 4.x
or 5.x, except for the Python distribution. It has been tested with
VC++ 4.2 on Python 1.5a3, and with VC++ 5.0 on Python 1.5b2.
The "example_nt" subdirectory should be an immediate subdirectory of
the 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
specific files inside the PC subdirectory of the distribution, where
they belong.)
It is also assumed that the build results of Python are in the
directory ..\vc40. In particular, the python15.lib file is referred
to as "..\vc40\python15.lib". If you have problems with this file,
the best thing to do is to delete it from the project and add it
again.
When using the VC++ 4.x project (makefile), it is assumed that the
build results of Python are in the directory ..\vc40. In particular,
the python15.lib file is referred to as "..\vc40\python15.lib". If
you have problems with this file, the best thing to do is to delete it
from the project and add it again.
In order to use the example project from Developer Studio, use the
"File->Open Workspace..." dialog (*not* the "File->Open..." dialog!).
Change the pattern to "*.mak" and select the file "example.mak". Now
choose "File->Save All" and the othe project files will be created.
When using the VC++ 5.x project (workspace), the build results of
Python are assumed to be in ..\PCbuild. Since the provided VC++ 5.x
project and workspace files have a different structure (to support
separate "release" and "debug" builds), the example project and
workspace match this structure.
In order to use the example project from VC++ 4.x, use the "File->Open
Workspace..." dialog (*not* the "File->Open..." dialog!). Change the
pattern to "*.mak" and select the file "example.mak". Now choose
"File->Save All" and the othe project files will be created.
From VC+ 5.x, do the same except don't change the pattern, and select
the example.dsw workspace file.
In order to check that everything is set up right, try building:
choose "Build->Build example.dll". This creates all intermediate and
result files in a subdirectory which is called either Debug or Release
depending on which configuration you have chosen (as distributed,
Debug is selected as the default configuration).
depending on which configuration you have chosen.
Once the build has succeeded, test the resulting DLL. In a DOS
command window, chdir to that directory. You should now be able to
@ -42,6 +50,14 @@ Python prompt):
Hello, world
>>>
When using VC++ 5.x, issue these commands:
C> ..\..\PCbuild\Release\python.exe
>>> import example
>>> example.foo()
Hello, world
>>>
Creating the project
--------------------
@ -66,14 +82,18 @@ spam\spam.mak. Do a global edit on spam.mak, replacing all
occurrences of the string "example" by "spam", and all occurrences of
"DEP_CPP_EXAMP" by something like "DEP_CPP_SPAM". You can now use
this makefile to create a project file by opening it as a workspace
(you have to change the pattern to *.mak first).
(you have to change the pattern to *.mak first). (When using VC++
5.x, you can clone example.dsp and example.dsw in a similar way.)
2) Create a brand new project; instructions are below.
In both cases, copy example_nt\example.def to spam\spam.def, and edit
spam\spam.def so its second line contains the string "initspam". If
you created a new project yourself, add the file spam.def to the
project now.
project now. (This is an annoying little file with only two lines.
An alternative approach is to forget about the .def file, and add the
option "/export:initspam" somewhere to the Link settings, by manually
editing the "Project Options" box).
You are now all set to build your extension, unless it requires other
external libraries, include files, etc. See Python's Extending and
@ -83,8 +103,9 @@ Embedding manual for instructions on how to write an extension.
Creating a brand new project
----------------------------
If you don't feel comfortable with editing Makefiles, you can create a
brand new project from scratch easily.
If you don't feel comfortable with editing Makefiles or project and
workspace files, you can create a brand new project from scratch
easily.
Use the "File->New..." dialog to create a new Project Workspace.
Select Dynamic-Link Library, enter the name ("spam"), and make sure
@ -102,7 +123,16 @@ box labeled "Addditional include directories:"
..\Include,..\PC
You must also change the run-time library. This must be done
Next, for both configurations, select the "Link" tab, choose the
"General" category, and add "python15.lib" to the end of the
"Object/library modules" box.
Then, separately for the Release and Debug configurations, choose the
"Input" category in the Link tab, and enter "..\PCbuild\Release" or
"..\PCbuild\Debug", respectively, in the "Additional library path"
box.
Finally, you must change the run-time library. This must also be done
separately for the Release and Debug configurations. Choose the "Code
Generation" category in the C/C++ tab. In the box labeled "Use
run-time library", choose "Multithreaded DLL" for the Release
@ -114,5 +144,5 @@ previous section.
Now chose the "Insert->Files into Project..." dialog. Set the pattern
to *.* and select both spam.c and spam.def and click OK. (Inserting
them one by one is fine too.) Using the same dialog, choose the file
..\vc40\python15.lib and insert it into the project.
them one by one is fine too.)