1.3.0 installation:
direct_init_.py (last line):
should say:
1.3.0 installation:
direct_init_.py (last line):
should say:
Josh,
in that regard please also have a look at:
[discourse.panda3d.org/viewtopic ... ght=py2exe](https://discourse.panda3d.org/viewtopic.php?t=901&highlight=py2exe)
essentially i think the direct module should be restructured from
direct/
__init__.py
src
actor
cluster
...
tkpanels
tkwidgets
to
direct/
__init__.py
actor
cluster
...
tkpanels
tkwidgets
and empty init.py (this was also suggested as a solution to make py2exe working better with panda3d).
same is true for linux (or OS X) anyways and it’s a more common python module structure.
maybe a small improvement worth in 1.3.1…
cheers,
kaweh
Hi I just got py2exe working using panda 1.3.2, but I had to make a change to pandac/extension_native_helpers.py to get it to work.
The problem is that py2exe changes the sys.path to include just the path to the compiled python files (library.zip) it creates. Read here for more details:
http://www.py2exe.org/index.cgi/Py2exeEnvironment
It seems that extension_native_hepers.py however uses sys.path to find the location of the libpandaexpress.dll
Anyways the following changes (marked w/ “#…#”) fixed it for me without interfering w/running my stuff through ppython or through the exe created via py2exe.
This code appears around Line 7 in extension_native_helpers.py
# Make sure the panda DLL directory is first on the path.
if (sys.platform == "win32"):
target = None
#<ASJ>
#Added the following line, simply adds the base dir from which
#your .exe is running (that's where py2exe puts libpandaexpress.dll).
#In the non py2exe world, this just appends the path of your python
#distro to the syspath so everything works normally
sys.path.append(sys.prefix)
#</ASJ>
for dir in sys.path:
lib = os.path.join(dir,"libpandaexpress.dll")
if (os.path.exists(lib)):
target = dir
if (target == None):
print "Cannot find libpandaexpress. Exiting."
#<ASJ>
#This said "os.exit(1)" before, caused a tissue when this error
#condition fires
sys.exit(1)
#</ASJ>
path=os.environ["PATH"]
if (path.startswith(target+";")==0):
os.environ["PATH"] = target+";"+path
I incorporated this suggestion, thank you!
David
The direct/init.py still says “exit”, could it be replaced with “sys.exit” ?
Hmm, this file isn’t part of the source tree; it is generated. I edited the ppremake scripts that generate it, but it appears it is also generated by makepanda. I guess a similar change needs to be made to makepanda as well.
I don’t know beans about makepanda, but you’ve been mucking around in there, pro-rsoft. Why don’t you give it a try?
David
yes, it’s there :
##########################################################################################
#
# Generate direct/__init__.py
#
##########################################################################################
DIRECTINIT="""
import os,sys
srcdir1 = os.path.join(__path__[0], 'src')
srcdir2 = os.path.join(__path__[0], '..', '..', 'direct', 'src')
if (os.path.isdir(srcdir1)): __path__[0] = srcdir1
elif (os.path.isdir(srcdir2)): __path__[0] = srcdir2
else: exit("Cannot find the 'direct' tree")
"""
Ah, I see Josh just checked in the fix to CVS. Thanks Josh!
I find it rather odd why makepanda works like this… It would be more logical for me to scrap this odd file, and also scrap the direct/src dir but move all directories directly inside direct/. I tried it and it worked excactly the same. (At least I had to do that manually for pyinstaller to work correctly.)