deploy-ng: fix issues with Mac/Python 2 build

This commit is contained in:
rdb 2016-12-05 18:54:37 -05:00
parent 70386795f4
commit f001bd20d7
3 changed files with 12 additions and 8 deletions

View File

@ -1556,10 +1556,10 @@ class Freezer:
if getattr(module, "__path__", None):
# Indicate package by negative size
size = -size
return struct.pack('<256sIi', bytes(modulename, 'ascii'), offset, size)
return struct.pack('<256sIi', modulename.encode('ascii'), offset, size)
def make_forbidden_module_list_entry(modulename):
return struct.pack('<256sIi', bytes(modulename, 'ascii'), 0, 0)
return struct.pack('<256sIi', modulename.encode('ascii'), 0, 0)
# We must have a __main__ module to make an exe file.
if not self.__writingModule('__main__'):

View File

@ -52,8 +52,11 @@ class build(distutils.command.build.build):
distutils.dir_util.copy_tree(src, dst)
for item in os.listdir(libdir):
if '.so.' in item or item.endswith('.dll') or 'libpandagl' in item:
distutils.file_util.copy_file(os.path.join(libdir, item), os.path.join(builddir, item))
if '.so.' in item or item.endswith('.dll') or item.endswith('.dylib') or 'libpandagl' in item:
source_path = os.path.join(libdir, item)
target_path = os.path.join(builddir, item)
if not os.path.islink(source_path):
distutils.file_util.copy_file(source_path, target_path)
# Copy etc
src = os.path.join(dtool_dir, '..', 'etc')
@ -64,8 +67,7 @@ class build(distutils.command.build.build):
ignore_copy_list = [
'__pycache__',
self.distribution.mainfile,
*freezer.getAllModuleNames(),
]
] + freezer.getAllModuleNames()
for item in os.listdir(gamedir):
src = os.path.join(gamedir, item)

View File

@ -122,11 +122,13 @@ Py_FrozenMain(int argc, char **argv)
else
sts = 0;
#if PY_MAJOR_VERSION >= 3
n = PyImport_ImportFrozenModule("_frozen_importlib");
if (n == 0)
Py_FatalError("_frozen_importlib not frozen");
if (n < 0)
PyErr_Print();
#endif
if (inspect && isatty((int)fileno(stdin)))
sts = PyRun_AnyFile(stdin, "<stdin>") != 0;
@ -153,7 +155,7 @@ error:
int
main(int argc, char *argv[]) {
struct _frozen *_PyImport_FrozenModules;
unsigned int listoff, modsoff, fsize, modsize, listsize, nummods;
unsigned int listoff, modsoff, fsize, modsize, listsize, nummods, modidx;
FILE *runtime = fopen(argv[0], "rb");
// Get offsets
@ -173,7 +175,7 @@ main(int argc, char *argv[]) {
// Read module list
_PyImport_FrozenModules = calloc(nummods + 1, sizeof(struct _frozen));
fseek(runtime, listoff, SEEK_SET);
for (unsigned int modidx = 0; modidx < nummods; ++modidx) {
for (modidx = 0; modidx < nummods; ++modidx) {
struct _frozen *moddef = &_PyImport_FrozenModules[modidx];
char *name = NULL, namebuf[256] = {0};
unsigned int nsize, codeptr;