From 6105f386c0a03cfe077431fe0b0e62646c783776 Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Sun, 3 Dec 2017 17:23:58 -0800 Subject: [PATCH] deploy-ng: Add a mechanism to FreezeTool for "hidden" imports For now we have hooks for PyTest and pkg_resources. --- direct/src/showutil/FreezeTool.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/direct/src/showutil/FreezeTool.py b/direct/src/showutil/FreezeTool.py index cec24b7c2d..029a9df9fc 100644 --- a/direct/src/showutil/FreezeTool.py +++ b/direct/src/showutil/FreezeTool.py @@ -59,6 +59,26 @@ builtinInitFuncs = { 'marshal': 'PyMarshal_Init', } +# These are modules that are not found normally for these modules. Add them +# to an include list so users do not have to do this manually. +try: + from pytest import freeze_includes as pytest_imports +except ImportError: + def pytest_imports(): + return [] + +hiddenImports = { + 'pytest': pytest_imports(), + 'pkg_resources': [ + 'pkg_resources.*.*', + # TODO why does the above not get these modules too? + 'pkg_resources._vendor.packaging.*', + 'pkg_resources._vendor.packaging.version', + 'pkg_resources._vendor.packaging.specifiers', + 'pkg_resources._vendor.packaging.requirements', + ], +} + # These are missing modules that we've reported already this session. reportedMissing = {} @@ -1043,6 +1063,10 @@ class Freezer: # module. pass + # Check if any new modules we found have "hidden" imports + for origName in list(self.mf.modules.keys()): + hidden = hiddenImports.get(origName, []) + # Now, any new modules we found get added to the export list. for origName in list(self.mf.modules.keys()): if origName not in origToNewName: