|
|
@@ -50,7 +50,7 @@ class CompilationEnvironment:
|
|
|
|
|
|
def __init__(self, platform):
|
|
|
self.platform = platform
|
|
|
-
|
|
|
+
|
|
|
# The command to compile a c to an object file. Replace %(basename)s
|
|
|
# with the basename of the source file, and an implicit .c extension.
|
|
|
self.compileObj = 'error'
|
|
|
@@ -144,11 +144,11 @@ class CompilationEnvironment:
|
|
|
|
|
|
else:
|
|
|
# Unix
|
|
|
- self.compileObj = "gcc -fPIC -c -o %(basename)s.o -O2 %(filename)s -I %(pythonIPath)s"
|
|
|
- self.linkExe = "gcc -o %(basename)s %(basename)s.o -lpython%(pythonVersion)s"
|
|
|
- self.linkDll = "gcc -shared -o %(basename)s.so %(basename)s.o -lpython%(pythonVersion)s"
|
|
|
+ self.compileObj = "gcc -fPIC -c -o %(basename)s.o -O2 %(filename)s -I%(pythonIPath)s"
|
|
|
+ self.linkExe = "gcc -o %(basename)s %(basename)s.o -L/usr/local/lib -lpython%(pythonVersion)s"
|
|
|
+ self.linkDll = "gcc -shared -o %(basename)s.so %(basename)s.o -L/usr/local/lib -lpython%(pythonVersion)s"
|
|
|
|
|
|
- if (platform.uname()[1]=="pcbsd"):
|
|
|
+ if (os.path.isdir("/usr/PCBSD/local/lib")):
|
|
|
self.linkExe += " -L/usr/PCBSD/local/lib"
|
|
|
self.linkDll += " -L/usr/PCBSD/local/lib"
|
|
|
|
|
|
@@ -314,7 +314,7 @@ void PyWinFreeze_ExeInit(void)
|
|
|
|
|
|
/*
|
|
|
Called by a frozen .EXE only, so that built-in extension
|
|
|
- modules are cleaned up
|
|
|
+ modules are cleaned up
|
|
|
*/
|
|
|
void PyWinFreeze_ExeTerm(void)
|
|
|
{
|
|
|
@@ -332,7 +332,7 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
|
|
|
{
|
|
|
BOOL ret = TRUE;
|
|
|
switch (dwReason) {
|
|
|
- case DLL_PROCESS_ATTACH:
|
|
|
+ case DLL_PROCESS_ATTACH:
|
|
|
{
|
|
|
char **modName;
|
|
|
for (modName = possibleModules;*modName;*modName++) {
|
|
|
@@ -342,7 +342,7 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
- case DLL_PROCESS_DETACH:
|
|
|
+ case DLL_PROCESS_DETACH:
|
|
|
{
|
|
|
// Must go backwards
|
|
|
char **modName;
|
|
|
@@ -398,7 +398,7 @@ static PyMethodDef nullMethods[] = {
|
|
|
* array of frozen modules, provided in a C-style array, at runtime.
|
|
|
* Returns the total number of frozen modules.
|
|
|
*/
|
|
|
-static int
|
|
|
+static int
|
|
|
extend_frozen_modules(const struct _frozen *new_modules, int new_count) {
|
|
|
int orig_count;
|
|
|
struct _frozen *realloc_FrozenModules;
|
|
|
@@ -644,7 +644,7 @@ class Freezer:
|
|
|
modulefinder.AddPackagePath(moduleName, path)
|
|
|
|
|
|
def getModulePath(self, moduleName):
|
|
|
- """ Looks for the indicated directory module and returns the
|
|
|
+ """ Looks for the indicated directory module and returns the
|
|
|
__path__ member: the list of directories in which its python
|
|
|
files can be found. If the module is a .py file and not a
|
|
|
directory, returns None. """
|
|
|
@@ -661,7 +661,7 @@ class Freezer:
|
|
|
for symbol in moduleName.split('.')[1:]:
|
|
|
module = getattr(module, symbol)
|
|
|
return module.__path__
|
|
|
-
|
|
|
+
|
|
|
# If it didn't work--maybe the module is unimportable because
|
|
|
# it makes certain assumptions about the builtins, or
|
|
|
# whatever--then just look for file on disk. That's usually
|
|
|
@@ -673,7 +673,7 @@ class Freezer:
|
|
|
path = self.getModulePath(parentName)
|
|
|
if path == None:
|
|
|
return None
|
|
|
-
|
|
|
+
|
|
|
file, pathname, description = imp.find_module(baseName, path)
|
|
|
|
|
|
if not os.path.isdir(pathname):
|
|
|
@@ -681,7 +681,7 @@ class Freezer:
|
|
|
return [pathname]
|
|
|
|
|
|
def getModuleStar(self, moduleName):
|
|
|
- """ Looks for the indicated directory module and returns the
|
|
|
+ """ Looks for the indicated directory module and returns the
|
|
|
__all__ member: the list of symbols within the module. """
|
|
|
|
|
|
# First, try to import the module directly. That's the most
|
|
|
@@ -697,7 +697,7 @@ class Freezer:
|
|
|
module = getattr(module, symbol)
|
|
|
if hasattr(module, '__all__'):
|
|
|
return module.__all__
|
|
|
-
|
|
|
+
|
|
|
# If it didn't work, just open the directory and scan for *.py
|
|
|
# files.
|
|
|
path = None
|
|
|
@@ -723,7 +723,7 @@ class Freezer:
|
|
|
modules.append(basename[:-3])
|
|
|
|
|
|
return modules
|
|
|
-
|
|
|
+
|
|
|
def addModule(self, moduleName, implicit = False, newName = None,
|
|
|
filename = None, guess = False, fromSource = None):
|
|
|
""" Adds a module to the list of modules to be exported by
|
|
|
@@ -802,7 +802,7 @@ class Freezer:
|
|
|
writeMultifile() to dump the resulting output. After a call
|
|
|
to done(), you may not add any more modules until you call
|
|
|
reset(). """
|
|
|
-
|
|
|
+
|
|
|
assert self.mf == None
|
|
|
|
|
|
# If we are building an exe, we also need to implicitly
|
|
|
@@ -815,7 +815,7 @@ class Freezer:
|
|
|
# Excluding a parent module also excludes all its
|
|
|
# (non-explicit) children, unless the parent has allowChildren
|
|
|
# set.
|
|
|
-
|
|
|
+
|
|
|
# Walk through the list in sorted order, so we reach parents
|
|
|
# before children.
|
|
|
names = self.modules.items()
|
|
|
@@ -877,7 +877,7 @@ class Freezer:
|
|
|
for origName in self.mf.modules.keys():
|
|
|
if origName not in origToNewName:
|
|
|
self.modules[origName] = self.ModuleDef(origName, implicit = True)
|
|
|
-
|
|
|
+
|
|
|
missing = []
|
|
|
for origName in self.mf.any_missing_maybe()[0]:
|
|
|
if origName in startupModules:
|
|
|
@@ -923,7 +923,7 @@ class Freezer:
|
|
|
|
|
|
def __loadModule(self, mdef):
|
|
|
""" Adds the indicated module to the modulefinder. """
|
|
|
-
|
|
|
+
|
|
|
if mdef.filename:
|
|
|
# If it has a filename, then we found it as a file on
|
|
|
# disk. In this case, the moduleName may not be accurate
|
|
|
@@ -961,7 +961,7 @@ class Freezer:
|
|
|
FreezeTool object for a new pass. More modules may be added
|
|
|
and dumped to a new target. Previously-added modules are
|
|
|
remembered and will not be dumped again. """
|
|
|
-
|
|
|
+
|
|
|
self.mf = None
|
|
|
self.previousModules = dict(self.modules)
|
|
|
|
|
|
@@ -993,7 +993,7 @@ class Freezer:
|
|
|
""" Return a list of all of the modules we will be explicitly
|
|
|
or implicitly including. The return value is actually a list
|
|
|
of tuples: (moduleName, moduleDef)."""
|
|
|
-
|
|
|
+
|
|
|
moduleDefs = []
|
|
|
|
|
|
for newName, mdef in self.modules.items():
|
|
|
@@ -1048,7 +1048,7 @@ class Freezer:
|
|
|
""" Adds all of the names on dirnames as a module directory. """
|
|
|
if not dirnames:
|
|
|
return
|
|
|
-
|
|
|
+
|
|
|
str = '.'.join(dirnames)
|
|
|
if str not in moduleDirs:
|
|
|
# Add an implicit __init__.py file.
|
|
|
@@ -1102,7 +1102,7 @@ class Freezer:
|
|
|
elif getattr(module, '__file__', None):
|
|
|
sourceFilename = Filename.fromOsSpecific(module.__file__)
|
|
|
sourceFilename.setExtension("py")
|
|
|
-
|
|
|
+
|
|
|
if self.storePythonSource:
|
|
|
if sourceFilename and sourceFilename.exists():
|
|
|
filename += '.py'
|
|
|
@@ -1152,7 +1152,7 @@ class Freezer:
|
|
|
if not mdef.exclude:
|
|
|
self.__addPythonFile(multifile, moduleDirs, moduleName, mdef,
|
|
|
compressionLevel)
|
|
|
-
|
|
|
+
|
|
|
def writeMultifile(self, mfname):
|
|
|
""" After a call to done(), this stores all of the accumulated
|
|
|
python code into a Multifile with the indicated filename,
|
|
|
@@ -1181,7 +1181,7 @@ class Freezer:
|
|
|
The return value is the newly-generated filename, including
|
|
|
the filename extension. Additional extension modules are
|
|
|
listed in self.extras. """
|
|
|
-
|
|
|
+
|
|
|
if compileToExe:
|
|
|
# We must have a __main__ module to make an exe file.
|
|
|
if not self.__writingModule('__main__'):
|
|
|
@@ -1193,7 +1193,7 @@ class Freezer:
|
|
|
# Now generate the actual export table.
|
|
|
moduleDefs = []
|
|
|
moduleList = []
|
|
|
-
|
|
|
+
|
|
|
for moduleName, mdef in self.getModuleDefs():
|
|
|
origName = mdef.moduleName
|
|
|
if mdef.forbid:
|
|
|
@@ -1247,7 +1247,7 @@ class Freezer:
|
|
|
|
|
|
if not self.cenv:
|
|
|
self.cenv = CompilationEnvironment(platform = self.platform)
|
|
|
-
|
|
|
+
|
|
|
if compileToExe:
|
|
|
code = self.frozenMainCode
|
|
|
if self.platform == 'win32':
|
|
|
@@ -1265,13 +1265,13 @@ class Freezer:
|
|
|
target = basename
|
|
|
|
|
|
compileFunc = self.cenv.compileExe
|
|
|
-
|
|
|
+
|
|
|
else:
|
|
|
if self.platform == 'win32':
|
|
|
target = basename + self.cenv.dllext + '.pyd'
|
|
|
else:
|
|
|
target = basename + '.so'
|
|
|
-
|
|
|
+
|
|
|
initCode = dllInitCode % {
|
|
|
'moduleName' : os.path.basename(basename),
|
|
|
'newcount' : len(moduleList),
|
|
|
@@ -1297,7 +1297,7 @@ class Freezer:
|
|
|
os.unlink(filename)
|
|
|
if (os.path.exists(basename + self.objectExtension)):
|
|
|
os.unlink(basename + self.objectExtension)
|
|
|
-
|
|
|
+
|
|
|
return target
|
|
|
|
|
|
def makeModuleDef(self, mangledName, code):
|
|
|
@@ -1325,7 +1325,7 @@ class Freezer:
|
|
|
""" Returns true if we are outputting the named module in this
|
|
|
pass, false if we have already output in a previous pass, or
|
|
|
if it is not yet on the output table. """
|
|
|
-
|
|
|
+
|
|
|
mdef = self.modules.get(moduleName, (None, None))
|
|
|
if mdef.exclude:
|
|
|
return False
|
|
|
@@ -1353,7 +1353,7 @@ class PandaModuleFinder(modulefinder.ModuleFinder):
|
|
|
partname = libname
|
|
|
fqname = libname
|
|
|
parent = None
|
|
|
-
|
|
|
+
|
|
|
return modulefinder.ModuleFinder.import_module(self, partname, fqname, parent)
|
|
|
|
|
|
def find_module(self, name, path, parent=None):
|
|
|
@@ -1382,7 +1382,7 @@ class PandaModuleFinder(modulefinder.ModuleFinder):
|
|
|
|
|
|
message = "DLL loader cannot find %s." % (name)
|
|
|
raise ImportError, message
|
|
|
-
|
|
|
+
|
|
|
def load_module(self, fqname, fp, pathname, (suffix, mode, type)):
|
|
|
if type == imp.PY_FROZEN:
|
|
|
# It's a frozen module.
|
|
|
@@ -1398,5 +1398,5 @@ class PandaModuleFinder(modulefinder.ModuleFinder):
|
|
|
self.scan_code(co, m)
|
|
|
self.msgout(2, "load_module ->", m)
|
|
|
return m
|
|
|
-
|
|
|
+
|
|
|
return modulefinder.ModuleFinder.load_module(self, fqname, fp, pathname, (suffix, mode, type))
|