David
Maybe i’m wrong … but packpanda create a package and not compiled files. I want compile files 'cos i guess i’ve frame rate gain.
I change my code in setup.py. It compiles fine but when i execute i have again “see log file” and now with this message:
Traceback (most recent call last):
File “main.py”, line 32, in
File “direct\particles\ParticleEffect.pyo”, line 197, in loadConfig
AssertionError: okflag at line 106 of c:\p\panda3d-1.5.4\built\include\virtualFileSystem.I
Yes, my demo got particles, but i didn’t understand a nut about this.
My new setup.py code:
my PY2EXE setup.py, works with the nasty \direct\src structure and it’s init.py
from distutils.core import setup
import os, glob, py2exe
##################################
PANDA_DIR = ‘c:\Panda3D-1.5.4’
##################################
directInit = os.path.join(PANDA_DIR, ‘direct/init.py’)
tempDirectInit = os.path.join(PANDA_DIR, ‘direct/__init__TEMP.py’)
tempNameDirectInit = os.path.join(PANDA_DIR, ‘direct/__init__TEMPNAME.py’)
def swapFileNames():
os.rename( directInit, tempNameDirectInit )
os.rename( tempDirectInit, directInit )
os.rename( tempNameDirectInit, tempDirectInit )
if empty init.py already exist, swap the names only (I’d like my HD clean),
otherwise rename the original into “temp” and create new EMPTY init.py
if os.path.exists(tempDirectInit): swapFileNames()
else:
os.rename( directInit, tempDirectInit )
emptyDirectInit = open(directInit,“w”)
emptyDirectInit.close()
try:
P3Dpackage_dir={}
directNpandac=[‘direct’,‘pandac’]
for d in directNpandac:
P3Dpackage_dir[d]=os.path.join(PANDA_DIR, d)
directTree=[ ‘direct.’+d for d in os.listdir(’%s\direct\src’ %PANDA_DIR) ]
for d in directTree:
P3Dpackage_dir[d]=os.path.join(PANDA_DIR, d.replace(’.’,’/src/’))
P3DmissingDLLs=glob.glob(os.path.join(PANDA_DIR, ‘bin/*.dll’))
some C/C++ runtime libraries, machine without these .dlls will crash Panda3D
runtimeLibraries=glob.glob(os.path.join(PANDA_DIR, ‘bin/.manifest’))+
glob.glob(os.path.join(PANDA_DIR, 'bin/vcredist.exe’))
############PY2EXE CONVERSION############
setup(
windows=[ { ‘script’ : ‘main.py’,
‘icon_resources’ : [ ( 1, ‘myLogo.ico’ ) ],
} ],
zipfile = None,
options = {
'py2exe': { 'optimize' : 2,
'excludes' : [ 'Tkinter' ],
'dist_dir' : 'dist/'},
},
data_files = [
( 'etc', glob.glob(os.path.join(PANDA_DIR, 'etc/*.*')) ),
( '.', P3DmissingDLLs ),
( '.', runtimeLibraries ),
("textures", glob.glob("textures/*.*"),
] ,
packages = directNpandac + directTree,
package_dir = P3Dpackage_dir,
)
########end_of_PY2EXE CONVERSION#########
finally:
restore direct_init_.py name, leave the empty one there,
so in the future, only need to swap the names, instead of creating it over and over again
swapFileNames()
print ‘\direct_init_.py filename restored
\n’
This code is a modified version from this thread https://discourse.panda3d.org/viewtopic.php?t=3579