make genPyCode work on Linux and non-ctattach platforms

This commit is contained in:
David Rose 2003-06-21 15:08:10 +00:00
parent de2502a7b0
commit 029f99a1cc
3 changed files with 33 additions and 14 deletions

View File

@ -694,6 +694,12 @@ class FFIInterrogateDatabase:
def generateCode(self, codeDir, extensionsDir):
# Empty out the codeDir of unnecessary crud from previous runs
# before we begin.
for file in os.listdir(codeDir):
pathname = os.path.join(codeDir, file)
os.unlink(pathname)
# Import all the C++ modules
for CModuleName in FFIConstants.CodeModuleNameList:
self.generateCodeLib(codeDir, extensionsDir, CModuleName)

View File

@ -330,17 +330,28 @@ exec "import %(start)s"
# create bootstrap code
fp = open(bootstrap, "w")
# Note: Jesse Schell changed the following line to be very
# panda specific
# Note: David Rose adjusted the following to be more general.
fp.write("""\
#%(localMagic)s %(archiveid)s
import ihooks,zlib,marshal,os
try:
directroot = os.environ["DIRECT"]
except KeyError:
print "Warning: environment variable DIRECT is not set."
directroot = ""
archivePath = directroot + "\\lib\\py\\%(archive)s"
import ihooks,zlib,marshal,os,sys
def searchPath(filename):
# Look along the python load path for the indicated filename.
# Returns the located pathname, or None if the filename is not
# found.
for dir in sys.path:
pathname = os.path.join(dir, filename)
if os.path.exists(pathname):
return pathname
return None
# Look for %(archive)s along the sys.path.
archiveName = "%(archive)s"
archivePath = searchPath(archiveName)
if archivePath == None:
raise ImportError, "Could not locate %%s on PYTHONPATH." %% (archiveName)
f=open(archivePath,"rb")
exec marshal.loads(%(zbegin)sf.read(%(loaderlen)d)%(zend)s)
boot("%(app)s",f,%(size)d)

View File

@ -3,7 +3,7 @@ import sys
import getopt
import pandaSqueezeTool
# Assumption: We will be squeezing the files from C:\Panda\lib\py
# Assumption: We will be squeezing the files from the current directory.
try:
opts, pargs = getopt.getopt(sys.argv[1:], 'O')
@ -22,8 +22,7 @@ for opt in opts:
print 'Squeezing pyo files'
def getSqueezeableFiles():
directDir = os.getenv('DIRECT')
fileList = os.listdir(directDir + "\lib\py")
fileList = os.listdir(".")
newFileList = []
if fOptimized:
targetFileExtension = ".pyo"
@ -32,12 +31,15 @@ def getSqueezeableFiles():
for i in fileList:
base,ext = os.path.splitext(i)
if (ext == ".py"):
j = directDir + "/lib/py/" + i
newFileList.append(j)
newFileList.append(i)
return newFileList
def squeezePandaFiles():
l = getSqueezeableFiles()
pandaSqueezeTool.squeeze("PandaModules", "PandaModulesUnsqueezed", l)
# Clean up the source files now that they've been squeezed.
for i in l:
os.unlink(i)
squeezePandaFiles()