Use Setuptools and importlib

Trying to build a panda with RenderPipeline using Setuptools, I encountered ambiguous behavior.
When using the importlib package, it is impossible to find the module.

I have modified the asteroids example to demonstrate the problem.

from direct.showbase.ShowBase import ShowBase

#import test
import importlib

class AsteroidsDemo(ShowBase):
    def __init__(self):

demo = AsteroidsDemo()

def ptest():
    print("Hello world")

There are two options for importing the module. Both work without packaging. However, after packaging, only the option that is commented out is workable.

The importlib option cannot find the module for some reason.

Known pipe types:
(all display modules loaded.)
Traceback (most recent call last):
  File "__main__", line 12, in <module>
  File "__main__", line 10, in __init__
  File "importlib", line 127, in import_module
  File "importlib._bootstrap", line 1006, in _gcd_import
  File "importlib._bootstrap", line 983, in _find_and_load
  File "importlib._bootstrap", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'test'

Does it help to explicitly add the module that you want to import via the “include_modules” section of your “” file?

We cannot detect this import. It is impossible to use static analysis to find all possible uses of importlib.

If you use importlib, then you must explicitly list the modules with include_modules.

For thirdparty packages that we know to use importlib or similar methods to import other modules, we usually create an entry here: