mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 09:52:27 -04:00
Python 3 fixes for rtdist builds
This commit is contained in:
parent
e02faec8ac
commit
7a681dc993
@ -63,8 +63,10 @@ class panda3d(package):
|
|||||||
|
|
||||||
# Include various standard Python encodings. The rest is in morepy.
|
# Include various standard Python encodings. The rest is in morepy.
|
||||||
module('encodings', 'encodings.aliases', 'encodings.undefined',
|
module('encodings', 'encodings.aliases', 'encodings.undefined',
|
||||||
'encodings.utf_8', 'encodings.ascii', 'encodings.string_escape',
|
'encodings.utf_8', 'encodings.ascii', 'encodings.mbcs',
|
||||||
'encodings.mbcs', 'encodings.latin_1', 'io')
|
'encodings.latin_1', 'io')
|
||||||
|
if sys.version_info < (3, 0):
|
||||||
|
module('encodings.string_escape')
|
||||||
|
|
||||||
# Pick up the shader files that appear in direct/src/filter.
|
# Pick up the shader files that appear in direct/src/filter.
|
||||||
import direct
|
import direct
|
||||||
|
@ -217,6 +217,24 @@ run_python() {
|
|||||||
PyModule_AddStringConstant(showbase_module, "__package__", "direct.showbase");
|
PyModule_AddStringConstant(showbase_module, "__package__", "direct.showbase");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PyObject *stdpy_module = PyImport_AddModule("direct.stdpy");
|
||||||
|
if (stdpy_module != NULL) {
|
||||||
|
Filename stdpy_dir(direct_dir, "stdpy");
|
||||||
|
dir_str = stdpy_dir.to_os_specific();
|
||||||
|
PyModule_AddObject(stdpy_module, "__path__", Py_BuildValue("[s#]", dir_str.data(), dir_str.length()));
|
||||||
|
PyModule_AddStringConstant(stdpy_module, "__package__", "direct.stdpy");
|
||||||
|
}
|
||||||
|
|
||||||
|
// And the encodings package as well, since we've presumably picked up a
|
||||||
|
// bunch of encodings modules as part of the frozen bundle.
|
||||||
|
Filename encodings_dir(dir, "encodings");
|
||||||
|
PyObject *encodings_module = PyImport_AddModule("encodings");
|
||||||
|
if (encodings_module != NULL) {
|
||||||
|
dir_str = encodings_dir.to_os_specific();
|
||||||
|
PyModule_AddObject(encodings_module, "__path__", Py_BuildValue("[s#]", dir_str.data(), dir_str.length()));
|
||||||
|
PyModule_AddStringConstant(encodings_module, "__package__", "encodings");
|
||||||
|
}
|
||||||
|
|
||||||
// And register the VFSImporter.
|
// And register the VFSImporter.
|
||||||
PyObject *result = PyObject_CallMethod(vfsimporter_module, (char *)"register", (char *)"");
|
PyObject *result = PyObject_CallMethod(vfsimporter_module, (char *)"register", (char *)"");
|
||||||
if (result == NULL) {
|
if (result == NULL) {
|
||||||
|
@ -2,6 +2,7 @@ __all__ = ['register', 'sharedPackages',
|
|||||||
'reloadSharedPackage', 'reloadSharedPackages']
|
'reloadSharedPackage', 'reloadSharedPackages']
|
||||||
|
|
||||||
from panda3d.core import Filename, VirtualFileSystem, VirtualFileMountSystem, OFileStream, copyStream
|
from panda3d.core import Filename, VirtualFileSystem, VirtualFileMountSystem, OFileStream, copyStream
|
||||||
|
from direct.stdpy.file import open
|
||||||
import sys
|
import sys
|
||||||
import marshal
|
import marshal
|
||||||
import imp
|
import imp
|
||||||
@ -173,10 +174,7 @@ class VFSLoader:
|
|||||||
filename = Filename(self.filename)
|
filename = Filename(self.filename)
|
||||||
filename.setExtension('py')
|
filename.setExtension('py')
|
||||||
filename.setText()
|
filename.setText()
|
||||||
vfile = vfs.getFile(filename)
|
return open(self.filename, self.desc[1]).read()
|
||||||
if not vfile:
|
|
||||||
raise IOError("Could not find '%s'" % (filename))
|
|
||||||
return vfile.readFile(True)
|
|
||||||
|
|
||||||
def _import_extension_module(self, fullname):
|
def _import_extension_module(self, fullname):
|
||||||
""" Loads the binary shared object as a Python module, and
|
""" Loads the binary shared object as a Python module, and
|
||||||
|
@ -1190,7 +1190,7 @@ class Freezer:
|
|||||||
|
|
||||||
if self.storePythonSource:
|
if self.storePythonSource:
|
||||||
filename += '.py'
|
filename += '.py'
|
||||||
stream = StringStream('')
|
stream = StringStream(b'')
|
||||||
if multifile.findSubfile(filename) < 0:
|
if multifile.findSubfile(filename) < 0:
|
||||||
multifile.addSubfile(filename, stream, 0)
|
multifile.addSubfile(filename, stream, 0)
|
||||||
multifile.flush()
|
multifile.flush()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user