Commits

Anonymous committed 7ee69d9

Fixed to work on PyS60 1.9.4
The pygame python files are compiled into byte-code. Feature of scons-for-symbian.

Comments (0)

Files changed (6)

symbian/BuildPygameRelease.py

              'sisversion'   : '"(1,%d,%d%s)"' % ( int(version[2:4]), int( version[4:6]),version[6:]),
              'pythonsis'    : sisname,
              'libpath'      : "data/pygame/libs",
-             'pycompiler'   : "d:\\python22\\python.exe"
+             'pycompiler'   : config.pycompiler
              }
     
     # Add certificate stuff

symbian/SConscript.app.py

+"""This is the build recipe for the pygame launcher application"""
+
 from scons_symbian import *
 
 # Import all from main SConstruct
 # Install pygame app resources
 from glob import glob
 
-def to_package(**kwargs):
+def doPackage(**kwargs):
     kwargs["source"] = abspath( kwargs["source"] )
     #kwargs["target"] = abspath( kwargs["target"] )
     ToPackage( package = PACKAGE_NAME, **kwargs )
 
-#for x in glob("*.bmp"):
-#    to_package( source = x, target = "data/pygame")
+def packagePyS60Stdlib(**kwargs):
+    kwargs["source"] = join( "deps/PythonForS60/module-repo/standard-modules", kwargs["source"] )
+    doPackage( **kwargs )
 
-to_package( source = "app/pygame_main.py", target = "data/pygame" )
-to_package( source = "app/launcher/logo.jpg", target = "data/pygame/launcher" )
-to_package( source = "app/launcher/pygame_launcher.py", target = "data/pygame/launcher" )
-to_package( source = "app/apps/liquid_s60.py", target = "data/pygame/apps" )
 
+doPackage( source = "app/pygame_main.py", target = "data/pygame", dopycompile=False )
+doPackage( source = "app/launcher/pygame_launcher.py", target = "data/pygame/launcher" )
 
+doPackage( source = "app/launcher/logo.jpg", target = "data/pygame/launcher" )
+doPackage( source = "app/apps/liquid_s60.py", target = "data/pygame/apps" )
+packagePyS60Stdlib( source = "glob.py",    target = "data/pygame/libs" )
+packagePyS60Stdlib( source = "fnmatch.py", target = "data/pygame/libs" )
+
+

symbian/app/launcher/pygame_launcher.py

                     # The launcher starts a new pygame.exe process for the selected application.
                     # This process must close before starting the new one.
                     p = os.path.abspath( join( THISDIR, "..", "pygame_main.py") )
-                    #TODO: Use start_server
-                    e32.start_exe( "251_python_launcher.exe", p )
+                    e32.start_server( p )
 
             else:         
                 # TODO: Use subprocess
         break
         
     pygame.quit()
-    
+
 if __name__ == "__main__":
-        
     if "profile" not in sys.argv:
         start()
     else:

symbian/app/pygame_main.cpp

 
 #ifndef PYGAME_MAIN_SCRIPT_PATH
 #define PYGAME_MAIN_SCRIPT_PATH "\\data\\pygame\\pygame_main.py"
-#define PYGAME_LAUNCHER_PATH    "\\data\\pygame\\launcher\\pygame_launcher.py"
+#define PYGAME_LAUNCHER_PATH    "\\data\\pygame\\launcher\\pygame_launcher.pyc"
 #endif
 static const char* gPygameMainScriptPath[2] = {
 		PYGAME_MAIN_SCRIPT_PATH,

symbian/app/pygame_main.py

 pygame main script for S60. This initializes some system defaults and 
 calls the pygame script given in sys.argv[1]
 """
+import imp
+import time
 import os
 import sys
 
 
 THISDIR = os.path.dirname( __file__ )
 sys.path.append( os.path.join( THISDIR, "libs") )
+
 if len(sys.argv) < 2:
     path_to_app = os.path.join( THISDIR, "launcher", "pygame_launcher.py" )
     if sys.platform == "symbian_s60":
             path_to_app = data.strip()
             
             # TODO: Make sure previous pygame.exe has closed first
-            import time
-            time.sleep(1)
-                         
+            time.sleep(1)                        
             e32.start_exe( "pygame.exe", path_to_app, 1)
             
             e32.start_exe( "pygame.exe", "")
-            
-        
+                    
 else:
 
     path_to_app = sys.argv[1]
         fold.close()
 
 try:
-    execfile(path_to_app, {'__builtins__': __builtins__,
-                   '__name__': '__main__',
-                   '__file__': path_to_app } )
+    
+    # Import the application module. This works with .pyc files as well unlike execfile
+    sys.path.append( os.path.dirname( path_to_app) )
+    
+    filename = os.path.basename(path_to_app)
+    filename = filename.split(".")
+    module  = ".".join( filename[:-1] )
+    
+    fp, pathname, stuff = imp.find_module(module)
+    try:
+        m = imp.load_module("__main__", fp, pathname, stuff)
+    finally:
+        if fp: fp.close()
+    
+        
 except:
     import traceback
     traceback.print_exc()

symbian/default_build_config.py

 # These are the defaults used by configure.py 
 # when build_config.py does not exist
-build_python = False
-pys60_ce_src = ''
-pys60_sis    = None
-pythondll    = 'python25'
-pythoninclude= r'/epoc32/include/python25'
+build_python  = False
+pys60_ce_src  = ''
+pys60_sis     = None
+pythondll     = 'python25'
+pythoninclude = r'/epoc32/include/python25'
+pycompiler    = "python"
 # Defaults for certificates
 cert         = None
 privkey      = None