[Zope-dev] python 2.0, windows and zope
Brian Lloyd
brian@digicool.com
Wed, 13 Dec 2000 14:14:32 -0500
This is a multi-part message in MIME format.
------=_NextPart_000_0002_01C0650F.03C94210
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
> Waffling on to my own posts... but it would seem I have to build Zope from
> source to get it to use another version of python since the use of
> python15.dll is entrenched in Zope... All the install scripts seem to be
> based on unix.
>
> Can DC give me a hand here on pointers to how they build it for Windows?
Hi Andy -
We have a little python script that creates NMAKE compatible
makefiles out of the Setup files. I've attached it + the .bat
file we use to run it. Hope this helps!
Brian Lloyd brian@digicool.com
Software Engineer 540.371.6909
Digital Creations http://www.digicool.com
------=_NextPart_000_0002_01C0650F.03C94210
Content-Type: text/plain;
name="ext15.py"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="ext15.py"
'''Build t Python extension using Visual C++ 40
This script generates and runs a series of .mak and .def
files for extensions defined in a Setup file.
Note that you must have set up your environment to run VC command-line
ustilities. This can be done by running the vcvar32.bat file in the
VC++ bin directory.
Usage: python ext.py [options]
Options:
-r Run nmake to build release version
-d Run nmake to build debug version
-c If used with -r or -d, runs nmake on clean target.
-p Specify location of Python source tree. Default
is ..\.. (assuming you are in Extensions/some_name)
The script reads a file named "Setup" in the current directory. The
Setup file has lines that describe the contents of an extension.
Here\'s an example:
ExtensionClass ExtensionClass.c
Acquisition Acquisition.c
Note that I\'ve intented for readability. The Setup file shouldn\'t
be indented. Basically, the first token on the line is the module
name, and the second token on the line is the sorce file. Additional
source files and include directories may be included as well, as in:
pyexpat pyexpat.c -DXML_NS -Iexpat/xmlparse -Iexpat/xmltok =
expat/xmlparse/xmlparse.c expat/xmlparse/hashtable.c =
expat/xmltok/xmlrole.c expat/xmltok/xmltok.c
''' # '
import sys, getopt, os, string, regex
def die(m):
print m
print
print __doc__
sys.exit(1)
def setup():
poptlist,pargs=3Dgetopt.getopt(sys.argv[1:],'p:drcI:o:h')
if opt(poptlist,'h'): print __doc__
if poptlist=3D=3D[('-h','')]: sys.exit(0)
pargs and die('Unrecognized arguments: %s', string.join(args))
ext_regex =3D regex.compile('\([a-z][a-z0-9_]*\)[ \t]'
'\([.a-z][./a-z0-9_]*[.]c\)[ \t\n]',
regex.casefold)
=20
for line in open('Setup').readlines():
=20
if ext_regex.match(line) >=3D 0:
sargs=3Dstring.split(line)
module=3Dsargs[0]
src=3Dsargs[1]
if src[:2]=3D=3D'./': continue
soptlist, sargs =3D getopt.getopt(sargs[2:],'I:D:')
filter(lambda a: a[:1]=3D=3D'-' or string.find(a,'.') < 0,
sargs) and die('Invalid arguments in Setup file: %s' %
string.join(sargs))
sargs=3Dmap(lambda a: string.replace(a, '/','\\'), sargs)
simple(module,poptlist+soptlist, sargs)
=20
main=3Dsetup
def filebase(o,
splitext=3Dos.path.splitext,
split=3Dos.path.split):
return splitext(split(o)[1])[0]
def simple(module,optlist,others):
tdef,tmak=3Dtemplates()
pyhome=3Dopt(optlist,'p')
pyhome=3Dpyhome and pyhome[0] or '..\\..'
cfg=3Dopt(optlist,'d') and 'Debug' or 'Release'
parms=3D{'module': module, 'pyhome':pyhome, 'cfg': cfg}
parms['includes']=3Dstring.join(
map(lambda i: '/I "%s"' % i,
opt(optlist,'I')) +
map(lambda i: '/D "%s"' % i,
opt(optlist,'D'))
, ' ')=20
parms['other_clean_release']=3Dstring.join(
map(lambda o:
'\n\t-@erase ".\\Release\\%s.obj"' % filebase(o),
others),'')
parms['other_clean_debug']=3Dstring.join(
map(lambda o:
'\n\t-@erase ".\\Debug\\%s.obj"' % filebase(o),
others),'')
parms['other_rule']=3Dstring.join(
map(lambda o:
'"$(INTDIR)\%s.obj" : .\%s $(DEP_CPP_MOD) "$(INTDIR)"\n'
'\t$(CPP) $(CPP_PROJ) .\%s '
% (filebase(o), o, o),
others),'\n')
parms['other_link']=3Dstring.join(
map(lambda o:
'\n\t"$(INTDIR)\%s.obj" \\' % filebase(o),
others),'')
open(module+'.def','w').write(tdef % parms)
open(module+'.mak','w').write(tmak % parms)
cfg_=3D' CFG=3D"%s - Win32 %s"' % (module,cfg)
os.system('nmake /nologo /f %s.mak%s' % (module,cfg_))
os.system('copy %s\%s.dll %s.pyd' % (cfg,module,module))
if opt(optlist,'c'):
os.system("nmake /f %s.mak%s CLEAN" % (module,cfg_))
def opt(optlist,name):
l=3Dfilter(lambda t, name=3D'-'+name: t[0]=3D=3Dname, optlist)
return map(lambda t: t[1], l)
def templates():
tdef =3D '''EXPORTS
init%(module)s
'''
tmak =3D '''# Microsoft Developer Studio Generated NMAKE File, =
Format Version 4.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
!IF "$(CFG)" =3D=3D ""
CFG=3D%(module)s - Win32 Debug
!MESSAGE No configuration specified. Defaulting to %(module)s - Win32 =
Debug.
!ENDIF=20
!IF "$(CFG)" !=3D "%(module)s - Win32 Release" && "$(CFG)" !=3D\\
"%(module)s - Win32 Debug"
!MESSAGE Invalid configuration "$(CFG)" specified.
!MESSAGE You can specify a configuration when running NMAKE on this =
makefile
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE=20
!MESSAGE NMAKE /f "%(module)s.mak" CFG=3D"%(module)s - Win32 Debug"
!MESSAGE=20
!MESSAGE Possible choices for configuration are:
!MESSAGE=20
!MESSAGE "%(module)s - Win32 Release" (based on\\
"Win32 (x86) Dynamic-Link Library")
!MESSAGE "%(module)s - Win32 Debug" (based on "Win32 (x86) Dynamic-Link =
Library")
!MESSAGE=20
!ERROR An invalid configuration is specified.
!ENDIF=20
!IF "$(OS)" =3D=3D "Windows_NT"
NULL=3D
!ELSE=20
NULL=3Dnul
!ENDIF=20
#########################################################################=
#######
# Begin Project
# PROP Target_Last_Scanned "%(module)s - Win32 Debug"
CPP=3Dcl.exe
RSC=3Drc.exe
MTL=3Dmktyplib.exe
!IF "$(CFG)" =3D=3D "%(module)s - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
OUTDIR=3D.\\Release
INTDIR=3D.\\Release
ALL : "$(OUTDIR)\\%(module)s.dll"
CLEAN :=20
-@erase ".\\Release\\%(module)s.dll"
-@erase ".\\Release\\%(module)s.obj"%(other_clean_release)s
-@erase ".\\Release\\%(module)s.lib"
-@erase ".\\Release\\%(module)s.exp"
-@erase ".\\Release\\%(module)s.pch"
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D =
"_WINDOWS" /YX /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "%(pyhome)s\\Include" /I =
"%(pyhome)s\\PC" %(includes)s /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX =
/c
CPP_PROJ=3D/nologo /MD /W3 /GX /O2 /I "%(pyhome)s\\Include" /I =
"%(pyhome)s\\PC" %(includes)s /D "WIN32" /D\\
"NDEBUG" /D "_WINDOWS" /Fp"$(INTDIR)/%(module)s.pch" /YX =
/Fo"$(INTDIR)/" /c=20
CPP_OBJS=3D.\\Release/
CPP_SBRS=3D
# ADD BASE MTL /nologo /D "NDEBUG" /win32
# ADD MTL /nologo /D "NDEBUG" /win32
MTL_PROJ=3D/nologo /D "NDEBUG" /win32=20
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=3Dbscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
BSC32_FLAGS=3D/nologo /o"$(OUTDIR)/%(module)s.bsc"=20
BSC32_SBRS=3D
LINK32=3Dlink.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib =
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib =
odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib =
advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib =
odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
LINK32_FLAGS=3Dkernel32.lib user32.lib gdi32.lib winspool.lib =
comdlg32.lib\\
advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\\
odbccp32.lib /nologo /subsystem:windows /dll /incremental:no\\
/pdb:"$(OUTDIR)/%(module)s.pdb" /machine:I386 =
/def:".\\%(module)s.def"\\
/out:"$(OUTDIR)/%(module)s.dll" /implib:"$(OUTDIR)/%(module)s.lib"=20
DEF_FILE=3D \\
".\\%(module)s.def"
LINK32_OBJS=3D \\
"$(INTDIR)/%(module)s.obj" \\%(other_link)s
"%(pyhome)s\\pcbuild\\%(cfg)s\\python15.lib"
"$(OUTDIR)\\%(module)s.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ELSEIF "$(CFG)" =3D=3D "%(module)s - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Target_Dir ""
OUTDIR=3D.\\Debug
INTDIR=3D.\\Debug
ALL : "$(OUTDIR)\\%(module)s.dll"
CLEAN :=20
-@erase ".\\Debug\\%(module)s.dll"
-@erase ".\\Debug\\%(module)s.obj"%(other_clean_debug)s
-@erase ".\\Debug\\%(module)s.ilk"
-@erase ".\\Debug\\%(module)s.lib"
-@erase ".\\Debug\\%(module)s.exp"
-@erase ".\\Debug\\%(module)s.pdb"
-@erase ".\\Debug\\%(module)s.pch"
-@erase ".\\Debug\\pcbuild.pdb"
-@erase ".\\Debug\\pcbuild.idb"
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" =
/D "_WINDOWS" /YX /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "%(pyhome)s\\Include" /I =
"%(pyhome)s\\PC" %(includes)s /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX =
/c
CPP_PROJ=3D/nologo /MDd /W3 /Gm /GX /Zi /Od /I "%(pyhome)s\\Include" /I =
"%(pyhome)s\\PC" %(includes)s /D "WIN32"\\
/D "_DEBUG" /D "_WINDOWS" /Fp"$(INTDIR)/%(module)s.pch" /YX =
/Fo"$(INTDIR)/"\\
/Fd"$(INTDIR)/" /c=20
CPP_OBJS=3D.\\Debug/
CPP_SBRS=3D
# ADD BASE MTL /nologo /D "_DEBUG" /win32
# ADD MTL /nologo /D "_DEBUG" /win32
MTL_PROJ=3D/nologo /D "_DEBUG" /win32=20
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=3Dbscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
BSC32_FLAGS=3D/nologo /o"$(OUTDIR)/%(module)s.bsc"=20
BSC32_SBRS=3D
LINK32=3Dlink.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib =
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib =
odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug =
/machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib =
advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib =
odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386
LINK32_FLAGS=3Dkernel32.lib user32.lib gdi32.lib winspool.lib =
comdlg32.lib\\
advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\\
odbccp32.lib /nologo /subsystem:windows /dll /incremental:yes\\
/pdb:"$(OUTDIR)/%(module)s.pdb" /debug /machine:I386 =
/def:".\\%(module)s.def"\\
/out:"$(OUTDIR)/%(module)s.dll" /implib:"$(OUTDIR)/%(module)s.lib"=20
DEF_FILE=3D \\
".\\%(module)s.def"
LINK32_OBJS=3D \\
"$(INTDIR)/%(module)s.obj" \\%(other_link)s
"%(pyhome)s\\pcbuild\\%(cfg)s\\python15.lib"
"$(OUTDIR)\\%(module)s.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ENDIF=20
.c{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $< =20
.cpp{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $< =20
.cxx{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $< =20
.c{$(CPP_SBRS)}.sbr:
$(CPP) $(CPP_PROJ) $< =20
.cpp{$(CPP_SBRS)}.sbr:
$(CPP) $(CPP_PROJ) $< =20
.cxx{$(CPP_SBRS)}.sbr:
$(CPP) $(CPP_PROJ) $< =20
#########################################################################=
#######
# Begin Target
# Name "%(module)s - Win32 Release"
# Name "%(module)s - Win32 Debug"
!IF "$(CFG)" =3D=3D "%(module)s - Win32 Release"
!ELSEIF "$(CFG)" =3D=3D "%(module)s - Win32 Debug"
!ENDIF=20
#########################################################################=
#######
# Begin Source File
SOURCE=3D.\\%(module)s.c
DEP_CPP_MOD=3D\\
"%(pyhome)s\\Include\\Python.h"\\
"%(pyhome)s\\PC\\config.h"\\
"%(pyhome)s\\Include\\myproto.h"\\
"%(pyhome)s\\Include\\object.h"\\
"%(pyhome)s\\Include\\objimpl.h"\\
"%(pyhome)s\\Include\\pydebug.h"\\
"%(pyhome)s\\Include\\intobject.h"\\
"%(pyhome)s\\Include\\longobject.h"\\
"%(pyhome)s\\Include\\floatobject.h"\\
"%(pyhome)s\\Include\\complexobject.h"\\
"%(pyhome)s\\Include\\rangeobject.h"\\
"%(pyhome)s\\Include\\stringobject.h"\\
"%(pyhome)s\\Include\\tupleobject.h"\\
"%(pyhome)s\\Include\\listobject.h"\\
"%(pyhome)s\\Include\\methodobject.h"\\
"%(pyhome)s\\Include\\moduleobject.h"\\
"%(pyhome)s\\Include\\funcobject.h"\\
"%(pyhome)s\\Include\\classobject.h"\\
"%(pyhome)s\\Include\\fileobject.h"\\
"%(pyhome)s\\Include\\cobject.h"\\
"%(pyhome)s\\Include\\traceback.h"\\
"%(pyhome)s\\Include\\sliceobject.h"\\
"%(pyhome)s\\Include\\pyerrors.h"\\
"%(pyhome)s\\Include\\mymalloc.h"\\
"%(pyhome)s\\Include\\modsupport.h"\\
"%(pyhome)s\\Include\\ceval.h"\\
"%(pyhome)s\\Include\\pythonrun.h"\\
"%(pyhome)s\\Include\\sysmodule.h"\\
"%(pyhome)s\\Include\\intrcheck.h"\\
"%(pyhome)s\\Include\\import.h"\\
"%(pyhome)s\\Include\\abstract.h"\\
"%(pyhome)s\\Include\\rename2.h"\\
"%(pyhome)s\\Include\\thread.h"\\
=09
"$(INTDIR)\\%(module)s.obj" : $(SOURCE) $(DEP_CPP_MOD) "$(INTDIR)"
%(other_rule)s
# End Source File
#########################################################################=
#######
# Begin Source File
SOURCE=3D.\\%(module)s.def
!IF "$(CFG)" =3D=3D "%(module)s - Win32 Release"
!ELSEIF "$(CFG)" =3D=3D "%(module)s - Win32 Debug"
!ENDIF=20
# End Source File
#########################################################################=
#######
# Begin Source File
SOURCE=3D%(pyhome)s\\pcbuild\\%(cfg)s\\python15.lib
!IF "$(CFG)" =3D=3D "%(module)s - Win32 Release"
!ELSEIF "$(CFG)" =3D=3D "%(module)s - Win32 Debug"
!ENDIF=20
# End Source File
#########################################################################=
#######
# Begin Source File
SOURCE=3D.\\readme.txt
!IF "$(CFG)" =3D=3D "%(module)s - Win32 Release"
!ELSEIF "$(CFG)" =3D=3D "%(module)s - Win32 Debug"
!ENDIF=20
# End Source File
# End Target
# End Project
#########################################################################=
#######
'''
return tdef, tmak
if __name__=3D=3D'__main__': main()
------=_NextPart_000_0002_01C0650F.03C94210
Content-Type: application/octet-stream;
name="ext15.bat"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="ext15.bat"
python p:/python/ext15.py %1 %2 %3 %4 %5 %6 %7 %8 %9
------=_NextPart_000_0002_01C0650F.03C94210--