3rd party library cranky in p3d

I use networkx for a game I am making. packp3d seems to work other than the ldd: not found bug. When I attempt to run the p3d I get the following error:

croxis@planata:~/src$ ./outpost.linux_amd64.p3d 
DirectStart: Starting the game.
:display: loading display module: libpandagl.so
:display: loading display module: libtinydisplay.so
Known pipe types:
  glxGraphicsPipe
  TinyXGraphicsPipe
  TinyOffscreenGraphicsPipe
(all display modules loaded.)
:ShowBase: Default graphics pipe is glxGraphicsPipe (OpenGL).
:pnmtext: Loaded font Perspective Sans Regular
:display: Unable to set window properties: !undecorated 
:ShowBase: Successfully opened window of type glxGraphicsWindow (OpenGL)
:ShowBase: __dev__ == 0
:gobj: Loading texture /mf/windowBorders/titleLeft.png
:gobj: Loading texture /mf/windowBorders/titleCenter.png
:gobj: Loading texture /mf/windowBorders/titleRight.png
:gobj: Loading texture /mf/windowBorders/titleRightClose.png
:gobj: Loading texture /mf/windowBorders/resize.png
:gobj: Loading texture /mf/windowBorders/scrollVerticalBorder.png
:gobj: Loading texture /mf/windowBorders/scrollVerticalDown.png
:gobj: Loading texture /mf/windowBorders/scrollVerticalUp.png
:gobj: Loading texture /mf/windowBorders/scrollVerticalBar.png
:gobj: Loading texture /mf/windowBorders/scrollHorizontalBorder.png
:gobj: Loading texture /mf/windowBorders/scrollHorizontalRight.png
:gobj: Loading texture /mf/windowBorders/scrollHorizontalLeft.png
:gobj: Loading texture /mf/windowBorders/scrollHorizontalBar.png
Traceback (most recent call last):
  File "/root/pandaworker/panda3d-1.7.0/built_cmu/direct/showbase/Messenger.py", line 352, in __taskChainDispatch
  File "/root/pandaworker/panda3d-1.7.0/built_cmu/direct/showbase/Messenger.py", line 410, in __dispatch
  File "/root/pandaworker/panda3d-1.7.0/built_cmu/direct/p3d/AppRunner.py", line 493, in __startIfReady
  File "VFSImporter", line 153, in load_module
  File "/home/croxis/src/Outpost/main.py", line 4, in <module>
    import Outpost
  File "VFSImporter", line 153, in load_module
  File "/home/croxis/src/Outpost/Outpost.py", line 51, in <module>
    import Game
  File "VFSImporter", line 153, in load_module
  File "/home/croxis/src/Outpost/Game.py", line 10, in <module>
    import Colony, Map
  File "VFSImporter", line 153, in load_module
  File "/home/croxis/src/Outpost/Colony.py", line 7, in <module>
    import networkx as nx
  File "VFSImporter", line 153, in load_module
  File "/usr/lib/pymodules/python2.6/networkx/__init__.py", line 51, in <module>
    from classes import *
  File "VFSImporter", line 153, in load_module
  File "/usr/lib/pymodules/python2.6/networkx/classes/__init__.py", line 2, in <module>
    from digraph import DiGraph
  File "VFSImporter", line 153, in load_module
  File "/usr/lib/pymodules/python2.6/networkx/classes/digraph.py", line 18, in <module>
    class DiGraph(Graph):
  File "/usr/lib/pymodules/python2.6/networkx/classes/digraph.py", line 59, in DiGraph
    add_node.__doc__ = Graph.add_node.__doc__.replace('Graph','DiGraph')
AttributeError: 'NoneType' object has no attribute 'replace'
:task(error): Exception occurred in PythonTask Messenger-default
Traceback (most recent call last):
  File "/root/pandaworker/panda3d-1.7.0/built_cmu/direct/p3d/AppRunner.py", line 411, in run
  File "/root/pandaworker/panda3d-1.7.0/built_cmu/direct/task/Task.py", line 496, in run
  File "/root/pandaworker/panda3d-1.7.0/built_cmu/direct/task/Task.py", line 454, in step
  File "/root/pandaworker/panda3d-1.7.0/built_cmu/direct/showbase/Messenger.py", line 352, in __taskChainDispatch
  File "/root/pandaworker/panda3d-1.7.0/built_cmu/direct/showbase/Messenger.py", line 410, in __dispatch
  File "/root/pandaworker/panda3d-1.7.0/built_cmu/direct/p3d/AppRunner.py", line 493, in __startIfReady
  File "VFSImporter", line 153, in load_module
  File "/home/croxis/src/Outpost/main.py", line 4, in <module>
    import Outpost
  File "VFSImporter", line 153, in load_module
  File "/home/croxis/src/Outpost/Outpost.py", line 51, in <module>
    import Game
  File "VFSImporter", line 153, in load_module
  File "/home/croxis/src/Outpost/Game.py", line 10, in <module>
    import Colony, Map
  File "VFSImporter", line 153, in load_module
  File "/home/croxis/src/Outpost/Colony.py", line 7, in <module>
    import networkx as nx
  File "VFSImporter", line 153, in load_module
  File "/usr/lib/pymodules/python2.6/networkx/__init__.py", line 51, in <module>
    from classes import *
  File "VFSImporter", line 153, in load_module
  File "/usr/lib/pymodules/python2.6/networkx/classes/__init__.py", line 2, in <module>
    from digraph import DiGraph
  File "VFSImporter", line 153, in load_module
  File "/usr/lib/pymodules/python2.6/networkx/classes/digraph.py", line 18, in <module>
    class DiGraph(Graph):
  File "/usr/lib/pymodules/python2.6/networkx/classes/digraph.py", line 59, in DiGraph
    add_node.__doc__ = Graph.add_node.__doc__.replace('Graph','DiGraph')
AttributeError: 'NoneType' object has no attribute 'replace'
:TaskManager: TaskManager.destroy()
:display: Closing glxGraphicsWindow
Successfully joined thread: 0
Failure on startup.

Program runs fine from source.

Hm, it must be related to the fact that the packager uses double-optimisation (-OO to python) to package the Python files. That can be bad, as -OO removes the docstrings as well (while -O doesn’t). This library apparently relies on the docstrings to be available, arguably a mistake in this library.

In fact, it looks like a really hacky nuisance in the networkx library. You could probably just edit the file in question (digraph.py) and simply comment out that line.

For academic reasons where would I hunt to change the packager to -O ?

That’s built into the runtime. If you wanted to avoid it, you could compile your own runtime, which is probably more work than you need to do; or you could simply run packp3d.py directly from the source (but you have to have the appropriate URL etc. built into the Panda3D library itself).

David