diff --git a/direct/src/p3d/AppRunner.py b/direct/src/p3d/AppRunner.py index cc2b61d902..3834cb48aa 100644 --- a/direct/src/p3d/AppRunner.py +++ b/direct/src/p3d/AppRunner.py @@ -192,6 +192,9 @@ class AppRunner(DirectObject): indicated host URL. If we have already seen this URL previously, returns the same object. """ + if hostUrl is None: + hostUrl = PandaSystem.getPackageHostUrl() + host = self.hosts.get(hostUrl, None) if not host: host = HostInfo(hostUrl, self) @@ -668,7 +671,7 @@ def dummyAppRunner(tokens = [], argv = None): hostUrl = PandaSystem.getPackageHostUrl() if platform.startswith('win'): - rootDir = Filename(Filename.getUserAppDataDirectory(), 'Panda3D') + rootDir = Filename(Filename.getUserAppdataDirectory(), 'Panda3D') else: rootDir = Filename(Filename.getHomeDirectory(), '.panda3d') diff --git a/direct/src/p3d/PackageInstaller.py b/direct/src/p3d/PackageInstaller.py index 4d141d7b75..8f62094826 100644 --- a/direct/src/p3d/PackageInstaller.py +++ b/direct/src/p3d/PackageInstaller.py @@ -1,5 +1,7 @@ from direct.showbase.DirectObject import DirectObject from direct.stdpy.threading import Lock +from direct.showbase.MessengerGlobal import messenger +from direct.task.TaskManagerGlobal import taskMgr class PackageInstaller(DirectObject): diff --git a/direct/src/p3d/Packager.py b/direct/src/p3d/Packager.py index 8efd549819..58787bfc8a 100644 --- a/direct/src/p3d/Packager.py +++ b/direct/src/p3d/Packager.py @@ -291,6 +291,10 @@ class Packager: # Every p3dapp requires 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 we don't have an implicit version, inherit the @@ -519,6 +523,8 @@ class Packager: self.packageDesc = packageDir + self.packageDesc self.packageImportDesc = packageDir + self.packageImportDesc + print "Generating %s" % (self.packageFilename) + self.packageFullpath = Filename(self.packager.installDir, self.packageFilename) self.packageFullpath.makeDir() @@ -1466,6 +1472,10 @@ class Packager: self.executablePath.appendDirectory('/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. self.platform = PandaSystem.getPlatform() @@ -1512,7 +1522,7 @@ class Packager: # Text files that are copied (and compressed) to the package # without processing. - self.textExtensions = [ 'prc', 'ptf', 'txt' ] + self.textExtensions = [ 'prc', 'ptf', 'txt', 'cg' ] # Binary files that are copied (and compressed) without # processing. @@ -1655,10 +1665,11 @@ class Packager: pm = PatchMaker(self.installDir) 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)) @@ -1710,20 +1721,21 @@ class Packager: try: for (lineno, stype, name, args, kw) in statements: 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: self.__evalFunc(name, args, kw) except PackagerError: diff --git a/direct/src/p3d/packp3d.py b/direct/src/p3d/packp3d.py index 275b15cc1c..fdb21bf439 100755 --- a/direct/src/p3d/packp3d.py +++ b/direct/src/p3d/packp3d.py @@ -46,7 +46,7 @@ Options: 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 secure deployment. + application intended for deployment. """ diff --git a/direct/src/p3d/ppackage.py b/direct/src/p3d/ppackage.py index f2eafc1c77..4bdbc32c86 100755 --- a/direct/src/p3d/ppackage.py +++ b/direct/src/p3d/ppackage.py @@ -22,15 +22,21 @@ This script is actually a wrapper around Panda's Packager.py. Usage: - %(prog)s [opts] package.pdef + %(prog)s [opts] package.pdef [packageName1 .. packageNameN] -Required: +Parameters: package.pdef The config file that describes the contents of the package file(s) to be built, in excruciating detail. See the Panda3D manual for 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: -i install_dir @@ -83,6 +89,15 @@ Options: appearing within the pdef file. This information is written to 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 Specify the platform to masquerade as. The default is whatever platform Panda has been built for. It is probably unwise to set @@ -108,7 +123,7 @@ packager = Packager.Packager() buildPatches = False 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: usage(1, msg) @@ -121,6 +136,8 @@ for opt, arg in opts: packager.installSearch.appendDirectory(Filename.fromOsSpecific(arg)) elif opt == '-d': packager.persistDir = Filename.fromOsSpecific(arg) + elif opt == '-D': + packager.allowPythonDev = True elif opt == '-P': packager.platform = arg elif opt == '-u': @@ -136,11 +153,11 @@ for opt, arg in opts: if not args: usage(0) - -if len(args) != 1: - usage(1) packageDef = Filename.fromOsSpecific(args[0]) +packageNames = None +if len(args) > 1: + packageNames = args[1:] if not packager.installDir: packager.installDir = Filename('install') @@ -148,7 +165,7 @@ packager.installSearch.prependDirectory(packager.installDir) try: packager.setup() - packages = packager.readPackageDef(packageDef) + packages = packager.readPackageDef(packageDef, packageNames = packageNames) packager.close() if buildPatches: packager.buildPatches(packages)