Browse Source

minor adjustments

David Rose 16 years ago
parent
commit
6f42852497

+ 4 - 1
direct/src/p3d/AppRunner.py

@@ -192,6 +192,9 @@ class AppRunner(DirectObject):
         indicated host URL.  If we have already seen this URL
         indicated host URL.  If we have already seen this URL
         previously, returns the same object. """
         previously, returns the same object. """
 
 
+        if hostUrl is None:
+            hostUrl = PandaSystem.getPackageHostUrl()
+
         host = self.hosts.get(hostUrl, None)
         host = self.hosts.get(hostUrl, None)
         if not host:
         if not host:
             host = HostInfo(hostUrl, self)
             host = HostInfo(hostUrl, self)
@@ -668,7 +671,7 @@ def dummyAppRunner(tokens = [], argv = None):
     hostUrl = PandaSystem.getPackageHostUrl()
     hostUrl = PandaSystem.getPackageHostUrl()
     
     
     if platform.startswith('win'):
     if platform.startswith('win'):
-        rootDir = Filename(Filename.getUserAppDataDirectory(), 'Panda3D')
+        rootDir = Filename(Filename.getUserAppdataDirectory(), 'Panda3D')
     else:
     else:
         rootDir = Filename(Filename.getHomeDirectory(), '.panda3d')
         rootDir = Filename(Filename.getHomeDirectory(), '.panda3d')
 
 

+ 2 - 0
direct/src/p3d/PackageInstaller.py

@@ -1,5 +1,7 @@
 from direct.showbase.DirectObject import DirectObject
 from direct.showbase.DirectObject import DirectObject
 from direct.stdpy.threading import Lock
 from direct.stdpy.threading import Lock
+from direct.showbase.MessengerGlobal import messenger
+from direct.task.TaskManagerGlobal import taskMgr
 
 
 class PackageInstaller(DirectObject):
 class PackageInstaller(DirectObject):
 
 

+ 31 - 19
direct/src/p3d/Packager.py

@@ -291,6 +291,10 @@ class Packager:
 
 
                 # Every p3dapp requires panda3d.
                 # Every p3dapp requires panda3d.
                 self.packager.do_require('panda3d')
                 self.packager.do_require('panda3d')
+
+                # If this flag is set, enable allow_python_dev.
+                if self.packager.allowPythonDev:
+                    self.configs['allow_python_dev'] = True
             
             
             if not self.p3dApplication and not self.version:
             if not self.p3dApplication and not self.version:
                 # If we don't have an implicit version, inherit the
                 # If we don't have an implicit version, inherit the
@@ -519,6 +523,8 @@ class Packager:
             self.packageDesc = packageDir + self.packageDesc
             self.packageDesc = packageDir + self.packageDesc
             self.packageImportDesc = packageDir + self.packageImportDesc
             self.packageImportDesc = packageDir + self.packageImportDesc
 
 
+            print "Generating %s" % (self.packageFilename)
+
             self.packageFullpath = Filename(self.packager.installDir, self.packageFilename)
             self.packageFullpath = Filename(self.packager.installDir, self.packageFilename)
             self.packageFullpath.makeDir()
             self.packageFullpath.makeDir()
 
 
@@ -1466,6 +1472,10 @@ class Packager:
             self.executablePath.appendDirectory('/lib')
             self.executablePath.appendDirectory('/lib')
             self.executablePath.appendDirectory('/usr/lib')
             self.executablePath.appendDirectory('/usr/lib')
 
 
+        # Set this flag true to automatically add allow_python_dev to
+        # any applications.
+        self.allowPythonDev = False
+
         # The platform string.
         # The platform string.
         self.platform = PandaSystem.getPlatform()
         self.platform = PandaSystem.getPlatform()
 
 
@@ -1512,7 +1522,7 @@ class Packager:
 
 
         # Text files that are copied (and compressed) to the package
         # Text files that are copied (and compressed) to the package
         # without processing.
         # without processing.
-        self.textExtensions = [ 'prc', 'ptf', 'txt' ]
+        self.textExtensions = [ 'prc', 'ptf', 'txt', 'cg' ]
 
 
         # Binary files that are copied (and compressed) without
         # Binary files that are copied (and compressed) without
         # processing.
         # processing.
@@ -1655,10 +1665,11 @@ class Packager:
         pm = PatchMaker(self.installDir)
         pm = PatchMaker(self.installDir)
         pm.buildPatches(packageNames = packageNames)
         pm.buildPatches(packageNames = packageNames)
 
 
-    def readPackageDef(self, packageDef):
-        """ Reads the named .pdef file and constructs the packages
-        indicated within it.  Raises an exception if the pdef file is
-        invalid.  Returns the list of packages constructed. """
+    def readPackageDef(self, packageDef, packageNames = None):
+        """ Reads the named .pdef file and constructs the named
+        packages, or all packages if packageNames is None.  Raises an
+        exception if the pdef file is invalid.  Returns the list of
+        packages constructed. """
 
 
         self.notify.info('Reading %s' % (packageDef))
         self.notify.info('Reading %s' % (packageDef))
 
 
@@ -1710,20 +1721,21 @@ class Packager:
         try:
         try:
             for (lineno, stype, name, args, kw) in statements:
             for (lineno, stype, name, args, kw) in statements:
                 if stype == 'class':
                 if stype == 'class':
-                    classDef = globals[name]
-                    p3dApplication = (class_p3d in classDef.__bases__)
-                    solo = (class_solo in classDef.__bases__)
-                    self.beginPackage(name, p3dApplication = p3dApplication,
-                                      solo = solo)
-                    statements = classDef.__dict__.get('__statements', [])
-                    if not statements:
-                        self.notify.info("No files added to %s" % (name))
-                    for (lineno, stype, name, args, kw) in statements:
-                        if stype == 'class':
-                            raise PackagerError, 'Nested classes not allowed'
-                        self.__evalFunc(name, args, kw)
-                    package = self.endPackage()
-                    packages.append(package)
+                    if packageNames is None or name in packageNames:
+                        classDef = globals[name]
+                        p3dApplication = (class_p3d in classDef.__bases__)
+                        solo = (class_solo in classDef.__bases__)
+                        self.beginPackage(name, p3dApplication = p3dApplication,
+                                          solo = solo)
+                        statements = classDef.__dict__.get('__statements', [])
+                        if not statements:
+                            self.notify.info("No files added to %s" % (name))
+                        for (lineno, stype, name, args, kw) in statements:
+                            if stype == 'class':
+                                raise PackagerError, 'Nested classes not allowed'
+                            self.__evalFunc(name, args, kw)
+                        package = self.endPackage()
+                        packages.append(package)
                 else:
                 else:
                     self.__evalFunc(name, args, kw)
                     self.__evalFunc(name, args, kw)
         except PackagerError:
         except PackagerError:

+ 1 - 1
direct/src/p3d/packp3d.py

@@ -46,7 +46,7 @@ Options:
      to the panda3d command, which enables a live Python prompt within
      to the panda3d command, which enables a live Python prompt within
      the application's environment.  Setting this flag may be useful
      the application's environment.  Setting this flag may be useful
      to develop an application initially, but should not be set on an
      to develop an application initially, but should not be set on an
-     application intended for secure deployment.
+     application intended for deployment.
 
 
 """
 """
 
 

+ 24 - 7
direct/src/p3d/ppackage.py

@@ -22,15 +22,21 @@ This script is actually a wrapper around Panda's Packager.py.
 
 
 Usage:
 Usage:
 
 
-  %(prog)s [opts] package.pdef
+  %(prog)s [opts] package.pdef [packageName1 .. packageNameN]
 
 
-Required:
+Parameters:
 
 
   package.pdef
   package.pdef
     The config file that describes the contents of the package file(s)
     The config file that describes the contents of the package file(s)
     to be built, in excruciating detail.  See the Panda3D manual for
     to be built, in excruciating detail.  See the Panda3D manual for
     the syntax of this file.
     the syntax of this file.
 
 
+  packageName1 .. packageNameN
+    Specify the names of the package(s) you wish to build out of the
+    package.pdef file.  This allows you to build only a subset of the
+    packages defined in this file.  If you omit these parameters, all
+    packages are built.
+
 Options:
 Options:
 
 
   -i install_dir
   -i install_dir
@@ -83,6 +89,15 @@ Options:
      appearing within the pdef file.  This information is written to
      appearing within the pdef file.  This information is written to
      the contents.xml file at the top of the install directory.
      the contents.xml file at the top of the install directory.
 
 
+  -D
+     Sets the allow_python_dev flag in any applications built with
+     this command.  This enables additional runtime debug operations,
+     particularly the -i option to the panda3d command, which enables
+     a live Python prompt within the application's environment.
+     Setting this flag may be useful to develop an application
+     initially, but should not be set on an application intended for
+     deployment.
+
   -P platform
   -P platform
      Specify the platform to masquerade as.  The default is whatever
      Specify the platform to masquerade as.  The default is whatever
      platform Panda has been built for.  It is probably unwise to set
      platform Panda has been built for.  It is probably unwise to set
@@ -108,7 +123,7 @@ packager = Packager.Packager()
 buildPatches = False
 buildPatches = False
 
 
 try:
 try:
-    opts, args = getopt.getopt(sys.argv[1:], 'i:ps:d:P:u:n:h')
+    opts, args = getopt.getopt(sys.argv[1:], 'i:ps:d:DP:u:n:h')
 except getopt.error, msg:
 except getopt.error, msg:
     usage(1, msg)
     usage(1, msg)
 
 
@@ -121,6 +136,8 @@ for opt, arg in opts:
         packager.installSearch.appendDirectory(Filename.fromOsSpecific(arg))
         packager.installSearch.appendDirectory(Filename.fromOsSpecific(arg))
     elif opt == '-d':
     elif opt == '-d':
         packager.persistDir = Filename.fromOsSpecific(arg)
         packager.persistDir = Filename.fromOsSpecific(arg)
+    elif opt == '-D':
+        packager.allowPythonDev = True
     elif opt == '-P':
     elif opt == '-P':
         packager.platform = arg
         packager.platform = arg
     elif opt == '-u':
     elif opt == '-u':
@@ -136,11 +153,11 @@ for opt, arg in opts:
 
 
 if not args:
 if not args:
     usage(0)
     usage(0)
-    
-if len(args) != 1:
-    usage(1)
 
 
 packageDef = Filename.fromOsSpecific(args[0])
 packageDef = Filename.fromOsSpecific(args[0])
+packageNames = None
+if len(args) > 1:
+    packageNames = args[1:]
 
 
 if not packager.installDir:
 if not packager.installDir:
     packager.installDir = Filename('install')
     packager.installDir = Filename('install')
@@ -148,7 +165,7 @@ packager.installSearch.prependDirectory(packager.installDir)
 
 
 try:
 try:
     packager.setup()
     packager.setup()
-    packages = packager.readPackageDef(packageDef)
+    packages = packager.readPackageDef(packageDef, packageNames = packageNames)
     packager.close()
     packager.close()
     if buildPatches:
     if buildPatches:
         packager.buildPatches(packages)
         packager.buildPatches(packages)