On Tue, Feb 3, 2009 at 6:54 PM, Lucio Torre <[email protected]> wrote:
>
> On Tue, Feb 3, 2009 at 6:43 PM, Anthony Lenton <[email protected]> 
> wrote:
> [we dont understand each other snipped]
>> Meanwhile, I should think that Cocos should avoid any call to
>> pyglet.resource.path or pyglet.resource.reindex, at least in it's
>> __init__.py file.
>
> we need to have access to the files under cocos/resources/ so some modules 
> work.
>
> how can we do that if we dont call those functions? what are you proposing?

Ah, ok.  Exactly.

Our options, at the moment (pick only one!):

1) Leave things as they are.  Report a bug to pyglet.  Hope.

2) Add a notice when the user imports cocos:
--- cocos/__init__.py   (revision 805)
+++ cocos/__init__.py   (working copy)
@@ -59,10 +59,17 @@


 # add the cocos resources path
-import os, pyglet
+import sys, os, pyglet
+
+if hasattr(sys, 'ps1'):
+    print """You seem to be running Python in an interactive session.
+    If importing Cocos takes an unreasonable amount of time, try unsetting your
+    PYTHONSTARTUP environment variable, or moving your $PYTHONSTARTUP file to a
+    directory of its own. """
+
 
pyglet.resource.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)),
"resources"))
 pyglet.resource.reindex()
-del os, pyglet
+del os, pyglet, sys


3) Dynamically patch sys.modules['__main__'].__file__ (I kind of
morbidly like this one):

--- cocos/__init__.py   (revision 805)
+++ cocos/__init__.py   (working copy)
@@ -59,10 +59,17 @@


 # add the cocos resources path
-import os, pyglet
+import sys, os, pyglet
+
+if 'PYTHONSTARTUP' in os.environ:
+    pythonrc = os.environ['PYTHONSTARTUP']
+    main = sys.modules['__main__']
+    if hasattr(main, '__file__') and main.__file__ == pythonrc:
+        del main.__file__
+
 
pyglet.resource.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)),
"resources"))
 pyglet.resource.reindex()
-del os, pyglet
+del os, pyglet, sys

4) Other ideas here.


-- 
Anthony Lenton

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"cocos2d discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cocos-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to