Setuptools: How to properly include ruamel.yaml?

I struggled to include ruamel.yaml into a binary distribution of my app, I believe because the name of the package contains the name of the sub package.

In order to include the package, its libraries and the related python files I had to add the following lines to my setup.py :

        'include_modules': {'*': ['_ruamel_yaml']},
        'package_data_dirs': {'ruamel': [('ruamel/*', 'ruamel', {})]},

Including ‘ruamel’, ‘ruamel.yaml’, … always lead to Unknown module warning. And without package_data_dirs, only the library is included, not the python support files.

The question is, is it a bug in setuptools or ruamel.yaml has simple a stupid name ?

What happens if you add ruamel.*.* to the modules list to attempt grabbing all submodules under ruamel?

Then I get a nice crash :slight_smile:

Building runtime for platform: manylinux1_x86_64
Traceback (most recent call last):
  File "setup.py", line 90, in 
    setup(**config)
  File "/usr/local/lib/python3.5/dist-packages/setuptools/__init__.py", line 145, in setup
    return distutils.core.setup(**attrs)
  File "/usr/lib/python3.5/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/usr/lib/python3.5/distutils/dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/usr/share/panda3d/direct/dist/commands.py", line 380, in run
    self.build_runtimes(platform, True)
  File "/usr/share/panda3d/direct/dist/commands.py", line 709, in build_runtimes
    create_runtime(appname, scriptname, False)
  File "/usr/share/panda3d/direct/dist/commands.py", line 639, in create_runtime
    freezer.addModule(incmod)
  File "/usr/share/panda3d/direct/dist/FreezeTool.py", line 1042, in addModule
    guess, fromSource, text))
  File "/usr/share/panda3d/direct/dist/FreezeTool.py", line 996, in _gatherSubmodules
    modules = self.getModuleStar(parentName)
  File "/usr/share/panda3d/direct/dist/FreezeTool.py", line 945, in getModuleStar
    file, pathname, description = imp.find_module(baseName, path)
  File "/usr/lib/python3.5/imp.py", line 270, in find_module
    "not {}".format(type(name)))
RuntimeError: 'list' must be None or a list, not < class 'str'>

Yikes! I am not sure what is going on here. Could you try a newer version of Python? I wonder if this is an incompatibility with 3.5, which doesn’t get tested as much with Panda as 3.6-3.8. Otherwise, I can try digging more into this soon (probably the weekend).

Similar problem with Python 3.7 using this include :

        'include_modules': {'*': ['ruamel.*.*']},
Building runtime for platform: manylinux1_x86_64
Traceback (most recent call last):
  File "setup.py", line 91, in 
    setup(**config)
  File "/usr/local/lib/python3.7/site-packages/setuptools/__init__.py", line 145, in setup
    return distutils.core.setup(**attrs)
  File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 966, in run_commands
    self.run_command(cmd)
  File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/Developer/Panda3D/direct/dist/commands.py", line 382, in run
    self.build_runtimes(platform, True)
  File "/Developer/Panda3D/direct/dist/commands.py", line 711, in build_runtimes
    create_runtime(appname, scriptname, False)
  File "/Developer/Panda3D/direct/dist/commands.py", line 641, in create_runtime
    freezer.addModule(incmod)
  File "/Developer/Panda3D/direct/dist/FreezeTool.py", line 1042, in addModule
    guess, fromSource, text))
  File "/Developer/Panda3D/direct/dist/FreezeTool.py", line 996, in _gatherSubmodules
    modules = self.getModuleStar(parentName)
  File "/Developer/Panda3D/direct/dist/FreezeTool.py", line 945, in getModuleStar
    file, pathname, description = imp.find_module(baseName, path)
  File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/imp.py", line 270, in find_module
    "not {}".format(type(path)))
RuntimeError: 'path' must be None or a list, not < class '_frozen_importlib_external._NamespacePath'>