mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 08:44:19 -04:00
build_apps: Allow setting hidden imports via setuptools options
This is exposed as a hidden_imports option, which is a dictionary. The keys are module name and the values are a list of modules to include when an import for the key is found.
This commit is contained in:
parent
c5017acb1d
commit
bd7b6d8fe7
11
direct/src/dist/FreezeTool.py
vendored
11
direct/src/dist/FreezeTool.py
vendored
@ -61,7 +61,7 @@ except ImportError:
|
|||||||
def pytest_imports():
|
def pytest_imports():
|
||||||
return []
|
return []
|
||||||
|
|
||||||
hiddenImports = {
|
defaultHiddenImports = {
|
||||||
'pytest': pytest_imports(),
|
'pytest': pytest_imports(),
|
||||||
'pkg_resources': [
|
'pkg_resources': [
|
||||||
'pkg_resources.*.*',
|
'pkg_resources.*.*',
|
||||||
@ -751,7 +751,7 @@ class Freezer:
|
|||||||
return 'ModuleDef(%s)' % (', '.join(args))
|
return 'ModuleDef(%s)' % (', '.join(args))
|
||||||
|
|
||||||
def __init__(self, previous = None, debugLevel = 0,
|
def __init__(self, previous = None, debugLevel = 0,
|
||||||
platform = None, path=None):
|
platform = None, path=None, hiddenImports=None):
|
||||||
# Normally, we are freezing for our own platform. Change this
|
# Normally, we are freezing for our own platform. Change this
|
||||||
# if untrue.
|
# if untrue.
|
||||||
self.platform = platform or PandaSystem.getPlatform()
|
self.platform = platform or PandaSystem.getPlatform()
|
||||||
@ -825,6 +825,11 @@ class Freezer:
|
|||||||
if path:
|
if path:
|
||||||
modulefinder.AddPackagePath(moduleName, path[0])
|
modulefinder.AddPackagePath(moduleName, path[0])
|
||||||
|
|
||||||
|
# Module with non-obvious dependencies
|
||||||
|
self.hiddenImports = defaultHiddenImports.copy()
|
||||||
|
if hiddenImports is not None:
|
||||||
|
self.hiddenImports.update(hiddenImports)
|
||||||
|
|
||||||
# Suffix/extension for Python C extension modules
|
# Suffix/extension for Python C extension modules
|
||||||
if self.platform == PandaSystem.getPlatform():
|
if self.platform == PandaSystem.getPlatform():
|
||||||
self.moduleSuffixes = imp.get_suffixes()
|
self.moduleSuffixes = imp.get_suffixes()
|
||||||
@ -1166,7 +1171,7 @@ class Freezer:
|
|||||||
|
|
||||||
# Check if any new modules we found have "hidden" imports
|
# Check if any new modules we found have "hidden" imports
|
||||||
for origName in list(self.mf.modules.keys()):
|
for origName in list(self.mf.modules.keys()):
|
||||||
hidden = hiddenImports.get(origName, [])
|
hidden = self.hiddenImports.get(origName, [])
|
||||||
for modname in hidden:
|
for modname in hidden:
|
||||||
if modname.endswith('.*'):
|
if modname.endswith('.*'):
|
||||||
mdefs = self._gatherSubmodules(modname, implicit = True)
|
mdefs = self._gatherSubmodules(modname, implicit = True)
|
||||||
|
11
direct/src/dist/commands.py
vendored
11
direct/src/dist/commands.py
vendored
@ -238,6 +238,7 @@ class build_apps(setuptools.Command):
|
|||||||
self.exclude_dependencies += ['bcrypt.dll']
|
self.exclude_dependencies += ['bcrypt.dll']
|
||||||
|
|
||||||
self.package_data_dirs = {}
|
self.package_data_dirs = {}
|
||||||
|
self.hidden_imports = {}
|
||||||
|
|
||||||
# We keep track of the zip files we've opened.
|
# We keep track of the zip files we've opened.
|
||||||
self._zip_files = {}
|
self._zip_files = {}
|
||||||
@ -271,6 +272,10 @@ class build_apps(setuptools.Command):
|
|||||||
self.platforms = _parse_list(self.platforms)
|
self.platforms = _parse_list(self.platforms)
|
||||||
self.plugins = _parse_list(self.plugins)
|
self.plugins = _parse_list(self.plugins)
|
||||||
self.extra_prc_files = _parse_list(self.extra_prc_files)
|
self.extra_prc_files = _parse_list(self.extra_prc_files)
|
||||||
|
self.hidden_imports = {
|
||||||
|
key: _parse_list(value)
|
||||||
|
for key, value in _parse_dict(self.hidden_imports).items()
|
||||||
|
}
|
||||||
|
|
||||||
if self.default_prc_dir is None:
|
if self.default_prc_dir is None:
|
||||||
self.default_prc_dir = '<auto>etc' if not self.embed_prc_data else ''
|
self.default_prc_dir = '<auto>etc' if not self.embed_prc_data else ''
|
||||||
@ -639,7 +644,11 @@ class build_apps(setuptools.Command):
|
|||||||
return search_path
|
return search_path
|
||||||
|
|
||||||
def create_runtime(appname, mainscript, use_console):
|
def create_runtime(appname, mainscript, use_console):
|
||||||
freezer = FreezeTool.Freezer(platform=platform, path=path)
|
freezer = FreezeTool.Freezer(
|
||||||
|
platform=platform,
|
||||||
|
path=path,
|
||||||
|
hiddenImports=self.hidden_imports
|
||||||
|
)
|
||||||
freezer.addModule('__main__', filename=mainscript)
|
freezer.addModule('__main__', filename=mainscript)
|
||||||
freezer.addModule('site', filename='site.py', text=SITE_PY)
|
freezer.addModule('site', filename='site.py', text=SITE_PY)
|
||||||
for incmod in self.include_modules.get(appname, []) + self.include_modules.get('*', []):
|
for incmod in self.include_modules.get(appname, []) + self.include_modules.get('*', []):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user