mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 01:07:51 -04:00
minor friendliness
This commit is contained in:
parent
3f5fd50c16
commit
f94479e13b
@ -1792,9 +1792,9 @@ class Packager:
|
|||||||
for keyword, value in kw.items():
|
for keyword, value in kw.items():
|
||||||
self.currentPackage.configs[keyword] = value
|
self.currentPackage.configs[keyword] = value
|
||||||
|
|
||||||
def do_require(self, packageName, version = None, host = None):
|
def do_require(self, *args, **kw):
|
||||||
""" Indicates a dependency on the named package, supplied as
|
""" Indicates a dependency on the named package(s), supplied
|
||||||
a name.
|
as a name.
|
||||||
|
|
||||||
Attempts to install this package will implicitly install the
|
Attempts to install this package will implicitly install the
|
||||||
named package also. Files already included in the named
|
named package also. Files already included in the named
|
||||||
@ -1803,22 +1803,35 @@ class Packager:
|
|||||||
if not self.currentPackage:
|
if not self.currentPackage:
|
||||||
raise OutsideOfPackageError
|
raise OutsideOfPackageError
|
||||||
|
|
||||||
# A special case when requiring the "panda3d" package. We
|
version = kw.get('version', None)
|
||||||
# supply the version number what we've been compiled with as a
|
host = kw.get('host', None)
|
||||||
# default.
|
|
||||||
if packageName == 'panda3d':
|
|
||||||
if version is None:
|
|
||||||
version = PandaSystem.getPackageVersionString()
|
|
||||||
if host is None:
|
|
||||||
host = PandaSystem.getPackageHostUrl()
|
|
||||||
|
|
||||||
package = self.findPackage(packageName, version = version, host = host,
|
|
||||||
requires = self.currentPackage.requires)
|
|
||||||
if not package:
|
|
||||||
message = 'Unknown package %s, version "%s"' % (packageName, version)
|
|
||||||
raise PackagerError, message
|
|
||||||
|
|
||||||
self.requirePackage(package)
|
for key in ['version', 'host']:
|
||||||
|
if key in kw:
|
||||||
|
del kw['version']
|
||||||
|
if kw:
|
||||||
|
message = "do_require() got an unexpected keyword argument '%s'" % (kw.keys()[0])
|
||||||
|
raise TypeError, message
|
||||||
|
|
||||||
|
for packageName in args:
|
||||||
|
# A special case when requiring the "panda3d" package. We
|
||||||
|
# supply the version number what we've been compiled with as a
|
||||||
|
# default.
|
||||||
|
pversion = version
|
||||||
|
phost = host
|
||||||
|
if packageName == 'panda3d':
|
||||||
|
if pversion is None:
|
||||||
|
pversion = PandaSystem.getPackageVersionString()
|
||||||
|
if phost is None:
|
||||||
|
phost = PandaSystem.getPackageHostUrl()
|
||||||
|
|
||||||
|
package = self.findPackage(packageName, version = pversion, host = phost,
|
||||||
|
requires = self.currentPackage.requires)
|
||||||
|
if not package:
|
||||||
|
message = 'Unknown package %s, version "%s"' % (packageName, version)
|
||||||
|
raise PackagerError, message
|
||||||
|
|
||||||
|
self.requirePackage(package)
|
||||||
|
|
||||||
def requirePackage(self, package):
|
def requirePackage(self, package):
|
||||||
""" Indicates a dependency on the indicated package, supplied
|
""" Indicates a dependency on the indicated package, supplied
|
||||||
@ -1842,21 +1855,32 @@ class Packager:
|
|||||||
|
|
||||||
self.currentPackage.requirePackage(package)
|
self.currentPackage.requirePackage(package)
|
||||||
|
|
||||||
def do_module(self, moduleName, newName = None):
|
def do_module(self, *args):
|
||||||
""" Adds the indicated Python module to the current package. """
|
""" Adds the indicated Python module(s) to the current package. """
|
||||||
|
|
||||||
|
if not self.currentPackage:
|
||||||
|
raise OutsideOfPackageError
|
||||||
|
|
||||||
|
for moduleName in args:
|
||||||
|
self.currentPackage.freezer.addModule(moduleName)
|
||||||
|
|
||||||
|
def do_renameModule(self, moduleName, newName):
|
||||||
|
""" Adds the indicated Python module to the current package,
|
||||||
|
renaming to a new name. """
|
||||||
|
|
||||||
if not self.currentPackage:
|
if not self.currentPackage:
|
||||||
raise OutsideOfPackageError
|
raise OutsideOfPackageError
|
||||||
|
|
||||||
self.currentPackage.freezer.addModule(moduleName, newName = newName)
|
self.currentPackage.freezer.addModule(moduleName, newName = newName)
|
||||||
|
|
||||||
def do_excludeModule(self, moduleName, forbid = False):
|
def do_excludeModule(self, *args):
|
||||||
""" Marks the indicated Python module as not to be included. """
|
""" Marks the indicated Python module as not to be included. """
|
||||||
|
|
||||||
if not self.currentPackage:
|
if not self.currentPackage:
|
||||||
raise OutsideOfPackageError
|
raise OutsideOfPackageError
|
||||||
|
|
||||||
self.currentPackage.freezer.excludeModule(moduleName, forbid = forbid)
|
for moduleName in args:
|
||||||
|
self.currentPackage.freezer.excludeModule(moduleName)
|
||||||
|
|
||||||
def do_mainModule(self, moduleName, newName = None, filename = None):
|
def do_mainModule(self, moduleName, newName = None, filename = None):
|
||||||
""" Names the indicated module as the "main" module of the
|
""" Names the indicated module as the "main" module of the
|
||||||
@ -1934,16 +1958,24 @@ class Packager:
|
|||||||
freezer.reset()
|
freezer.reset()
|
||||||
package.mainModule = None
|
package.mainModule = None
|
||||||
|
|
||||||
def do_file(self, filename, text = None, newNameOrDir = None,
|
def do_file(self, *args, **kw):
|
||||||
|
""" Adds the indicated file or files to the current package.
|
||||||
|
See addFiles(). """
|
||||||
|
|
||||||
|
self.addFiles(args, **kw)
|
||||||
|
|
||||||
|
def addFiles(self, filenames, text = None, newNameOrDir = None,
|
||||||
extract = None, executable = None, deleteTemp = False,
|
extract = None, executable = None, deleteTemp = False,
|
||||||
literal = False):
|
literal = False):
|
||||||
""" Adds the indicated arbitrary file to the current package.
|
|
||||||
|
|
||||||
The file is placed in the named directory, or the toplevel
|
""" Adds the indicated arbitrary files to the current package.
|
||||||
|
|
||||||
|
filenames is a list of Filename or string objects, and each
|
||||||
|
may include shell globbing characters.
|
||||||
|
|
||||||
|
Each file is placed in the named directory, or the toplevel
|
||||||
directory if no directory is specified.
|
directory if no directory is specified.
|
||||||
|
|
||||||
The filename may include shell globbing characters.
|
|
||||||
|
|
||||||
Certain special behavior is invoked based on the filename
|
Certain special behavior is invoked based on the filename
|
||||||
extension. For instance, .py files may be automatically
|
extension. For instance, .py files may be automatically
|
||||||
compiled and stored as Python modules.
|
compiled and stored as Python modules.
|
||||||
@ -1981,28 +2013,34 @@ class Packager:
|
|||||||
if not self.currentPackage:
|
if not self.currentPackage:
|
||||||
raise OutsideOfPackageError
|
raise OutsideOfPackageError
|
||||||
|
|
||||||
filename = Filename(filename)
|
files = []
|
||||||
|
explicit = True
|
||||||
|
|
||||||
|
for filename in filenames:
|
||||||
|
filename = Filename(filename)
|
||||||
|
|
||||||
if literal:
|
if literal:
|
||||||
files = [filename.toOsSpecific()]
|
thisFiles = [filename.toOsSpecific()]
|
||||||
|
|
||||||
else:
|
else:
|
||||||
ext = filename.getExtension()
|
ext = filename.getExtension()
|
||||||
|
|
||||||
# A special case, since OSX and Linux don't have a
|
# A special case, since OSX and Linux don't have a
|
||||||
# standard extension for program files.
|
# standard extension for program files.
|
||||||
if executable is None and ext == 'exe':
|
if executable is None and ext == 'exe':
|
||||||
executable = True
|
executable = True
|
||||||
|
|
||||||
newExt = self.remapExtensions.get(ext, None)
|
newExt = self.remapExtensions.get(ext, None)
|
||||||
if newExt is not None:
|
if newExt is not None:
|
||||||
filename.setExtension(newExt)
|
filename.setExtension(newExt)
|
||||||
|
|
||||||
files = glob.glob(filename.toOsSpecific())
|
thisFiles = glob.glob(filename.toOsSpecific())
|
||||||
if not files:
|
if not thisFiles:
|
||||||
files = [filename.toOsSpecific()]
|
thisFiles = [filename.toOsSpecific()]
|
||||||
|
|
||||||
explicit = (len(files) == 1)
|
if len(thisFiles) > 1:
|
||||||
|
explicit = False
|
||||||
|
files += thisFiles
|
||||||
|
|
||||||
newName = None
|
newName = None
|
||||||
prefix = ''
|
prefix = ''
|
||||||
@ -2017,8 +2055,11 @@ class Packager:
|
|||||||
raise PackagerError, message
|
raise PackagerError, message
|
||||||
|
|
||||||
if text:
|
if text:
|
||||||
|
if len(files) != 1:
|
||||||
|
message = 'Cannot install text to multiple files'
|
||||||
|
raise PackagerError, message
|
||||||
if not newName:
|
if not newName:
|
||||||
newName = filename.cStr()
|
newName = str(filenames[0])
|
||||||
|
|
||||||
tempFile = Filename.temporary('', self.currentPackage.packageName)
|
tempFile = Filename.temporary('', self.currentPackage.packageName)
|
||||||
temp = open(tempFile.toOsSpecific(), 'w')
|
temp = open(tempFile.toOsSpecific(), 'w')
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
|
|
||||||
class panda3d(package):
|
class panda3d(package):
|
||||||
|
|
||||||
# The core Panda3D package. Contains Python and most of the graphics
|
# The core Panda3D package. Contains Python and most of the graphics
|
||||||
# code in Panda3D.
|
# code in Panda3D.
|
||||||
|
|
||||||
@ -26,26 +25,26 @@ class panda3d(package):
|
|||||||
|
|
||||||
# These are additional Python modules that are needed by most Panda3D
|
# These are additional Python modules that are needed by most Panda3D
|
||||||
# applications. It doesn't matter too much if we miss one or two
|
# applications. It doesn't matter too much if we miss one or two
|
||||||
# here, since any module('imported by any of this code will')
|
# here, since any module imported by any of this code will
|
||||||
# automatically be included as well, and we end up with a pretty
|
# automatically be included as well, and we end up with a pretty
|
||||||
# complete list that way.
|
# complete list that way.
|
||||||
module('direct.directbase.DirectStart')
|
module('direct.directbase.DirectStart',
|
||||||
module('direct.showbase.*')
|
'direct.showbase.*',
|
||||||
module('direct.actor.Actor')
|
'direct.actor.Actor',
|
||||||
module('direct.fsm.FSM')
|
'direct.fsm.FSM',
|
||||||
module('direct.interval.IntervalGlobal')
|
'direct.interval.IntervalGlobal',
|
||||||
module('direct.particles.ParticleEffect')
|
'direct.particles.ParticleEffect',
|
||||||
module('direct.directutil.Mopath')
|
'direct.directutil.Mopath')
|
||||||
|
|
||||||
# Exclude these GUI toolkits; they're big, and many applications don't
|
# Exclude these GUI toolkits; they're big, and many applications don't
|
||||||
# use them. We define them as separate, optional packages, below.
|
# use them. We define them as separate, optional packages, below.
|
||||||
excludeModule('wx')
|
excludeModule('wx',
|
||||||
excludeModule('direct.showbase.WxGlobal')
|
'direct.showbase.WxGlobal')
|
||||||
|
|
||||||
excludeModule('Tkinter')
|
excludeModule('Tkinter',
|
||||||
excludeModule('direct.showbase.TkGlobal')
|
'direct.showbase.TkGlobal',
|
||||||
excludeModule('direct.tkpanels')
|
'direct.tkpanels',
|
||||||
excludeModule('direct.tkwidgets')
|
'direct.tkwidgets')
|
||||||
|
|
||||||
# Bind all of the above Python code into a frozen DLL. This makes the
|
# Bind all of the above Python code into a frozen DLL. This makes the
|
||||||
# Python code available when the DLL is imported. It is actually
|
# Python code available when the DLL is imported. It is actually
|
||||||
@ -69,11 +68,9 @@ class panda3d(package):
|
|||||||
# that are also needed, but aren't referenced by any code. Again,
|
# that are also needed, but aren't referenced by any code. Again,
|
||||||
# note that the .dll extension is automatically replaced with the
|
# note that the .dll extension is automatically replaced with the
|
||||||
# platform-specific extension for an executable.
|
# platform-specific extension for an executable.
|
||||||
file('libpandagl.dll')
|
file('libpandagl.dll', 'libtinydisplay.dll')
|
||||||
if platform.startswith('win'):
|
if platform.startswith('win'):
|
||||||
file('libpandadx8.dll')
|
file('libpandadx8.dll', 'libpandadx9.dll')
|
||||||
file('libpandadx9.dll')
|
|
||||||
file('libtinydisplay.dll')
|
|
||||||
|
|
||||||
# A basic config file is needed to lay some some fundamental runtime
|
# A basic config file is needed to lay some some fundamental runtime
|
||||||
# variables.
|
# variables.
|
||||||
@ -97,7 +94,6 @@ default-model-extension .bam
|
|||||||
|
|
||||||
|
|
||||||
class egg(package):
|
class egg(package):
|
||||||
|
|
||||||
# This package contains the code for reading and operating on egg
|
# This package contains the code for reading and operating on egg
|
||||||
# files. Since the Packager automatically converts egg files to bam
|
# files. Since the Packager automatically converts egg files to bam
|
||||||
# files, this is not needed for most Panda3D applications.
|
# files, this is not needed for most Panda3D applications.
|
||||||
@ -116,47 +112,41 @@ class wx(package):
|
|||||||
config(display_name = "wxPython GUI Toolkit")
|
config(display_name = "wxPython GUI Toolkit")
|
||||||
require('panda3d')
|
require('panda3d')
|
||||||
|
|
||||||
module('direct.showbase.WxGlobal')
|
module('direct.showbase.WxGlobal', 'wx', 'wx.*')
|
||||||
module('wx')
|
|
||||||
module('wx.*')
|
|
||||||
|
|
||||||
|
|
||||||
class tk(package):
|
class tk(package):
|
||||||
config(display_name = "Tk GUI Toolkit")
|
config(display_name = "Tk GUI Toolkit")
|
||||||
require('panda3d')
|
require('panda3d')
|
||||||
|
|
||||||
module('Tkinter')
|
module('Tkinter',
|
||||||
module('direct.showbase.TkGlobal')
|
'direct.showbase.TkGlobal',
|
||||||
module('direct.tkpanels')
|
'direct.tkpanels',
|
||||||
module('direct.tkwidgets')
|
'direct.tkwidgets')
|
||||||
|
|
||||||
class packp3d(p3d):
|
class packp3d(p3d):
|
||||||
|
|
||||||
# This application is a command-line convenience for building a p3d
|
# This application is a command-line convenience for building a p3d
|
||||||
# application out of a directory hierarchy on disk. We build it here
|
# application out of a directory hierarchy on disk. We build it here
|
||||||
# into its own p3d application, to allow end-users to easily build p3d
|
# into its own p3d application, to allow end-users to easily build p3d
|
||||||
# applications using the appropriate version of Python and Panda for
|
# applications using the appropriate version of Python and Panda for
|
||||||
# the targeted runtime.
|
# the targeted runtime.
|
||||||
|
|
||||||
config(display_name = "Panda3D Application Packer")
|
config(display_name = "Panda3D Application Packer",
|
||||||
config(full_disk_access = True)
|
full_disk_access = True,
|
||||||
config(hidden = True)
|
hidden = True)
|
||||||
require('panda3d')
|
require('panda3d', 'egg')
|
||||||
require('egg')
|
|
||||||
|
|
||||||
mainModule('direct.p3d.packp3d')
|
mainModule('direct.p3d.packp3d')
|
||||||
|
|
||||||
|
|
||||||
class ppackage(p3d):
|
class ppackage(p3d):
|
||||||
|
|
||||||
# As above, a packaging utility. This is the fully-general ppackage
|
# As above, a packaging utility. This is the fully-general ppackage
|
||||||
# utility, which reads pdef files (like this one!) and creates one or
|
# utility, which reads pdef files (like this one!) and creates one or
|
||||||
# more packages or p3d applications.
|
# more packages or p3d applications.
|
||||||
|
|
||||||
config(display_name = "Panda3D General Package Utility")
|
config(display_name = "Panda3D General Package Utility",
|
||||||
config(full_disk_access = True)
|
full_disk_access = True,
|
||||||
config(hidden = True)
|
hidden = True)
|
||||||
require('panda3d')
|
require('panda3d', 'egg')
|
||||||
require('egg')
|
|
||||||
|
|
||||||
mainModule('direct.p3d.ppackage')
|
mainModule('direct.p3d.ppackage')
|
||||||
|
@ -34,6 +34,9 @@ startupModules = [
|
|||||||
'org',
|
'org',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# These are missing modules that we've reported already this session.
|
||||||
|
reportedMissing = {}
|
||||||
|
|
||||||
# Our own Python source trees to watch out for.
|
# Our own Python source trees to watch out for.
|
||||||
sourceTrees = ['direct']
|
sourceTrees = ['direct']
|
||||||
|
|
||||||
@ -791,19 +794,13 @@ class Freezer:
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
prefix = origName.split('.')[0]
|
prefix = origName.split('.')[0]
|
||||||
if prefix not in sourceTrees:
|
if origName not in reportedMissing:
|
||||||
# If it's in not one of our standard source trees, assume
|
missing.append(origName)
|
||||||
# it's some wacky system file we don't need.
|
reportedMissing[origName] = True
|
||||||
print "ignoring missing %s" % (origName)
|
|
||||||
continue
|
|
||||||
|
|
||||||
missing.append(origName)
|
|
||||||
|
|
||||||
if missing:
|
if missing:
|
||||||
error = "There are some missing modules: %r" % missing
|
missing.sort()
|
||||||
print error
|
print "There are some missing modules: %r" % missing
|
||||||
print "previous = %s" % (self.previousModules,)
|
|
||||||
raise StandardError, error
|
|
||||||
|
|
||||||
def __loadModule(self, mdef):
|
def __loadModule(self, mdef):
|
||||||
""" Adds the indicated module to the modulefinder. """
|
""" Adds the indicated module to the modulefinder. """
|
||||||
|
Loading…
x
Reference in New Issue
Block a user