Hi, I've been using PyInstaller to compile a program that uses the 
ruamel.yaml package 
(https://sourceforge.net/p/ruamel-yaml/code/ci/default/tree/). I was using 
PyInstaller 3.6 on Fedora 30 with Python 3.7 and version 0.15.41 of 
ruamel.yaml. Everything was working fine under these conditions, but when I 
tried to use anything >= 0.16.0 of ruamel.yaml my PyInstaller compiled 
program would throw an ImportError. I've since migrated to Fedora 32 and 
started using the latest dev version of PyInstaller and not only is the 
ruamel.yaml issue still present but I no longer have the option to use 
ruamel.yaml < 0.16.0. I know that with 0.16.0 the c source was split to a 
different package and I think that's what's causing the issue. After 
writing some test scripts (attached) I've discovered that the compiled 
script can import ruamel.yaml but can't properly import any of the 
submodules or execute the __init__ properly (which imports everything from 
ruamel.yaml.main as part of ruamel.yaml). I've attempted to write a hook 
(attached) to overcome this, which makes my test script run properly, but 
ruamel.yaml still isn't imported properly which is still causing problem 
with the original program. I can also see in the PYZ-00.pyz that all the 
submodules are there when using < 0.16.0 but not there when using >=0.16.0.

*Output of my script using Python*:
['AliasEvent', 'AliasToken', 'AnchorToken', 'BaseConstructor', 
'BaseDumper', 'BaseLoader', 'BaseRepresenter', 'BlockEndToken', 
'BlockEntryToken', 'BlockMappingStartToken', 'BlockSequenceStartToken', 
'BytesIO', 'CBaseDumper', 'CBaseLoader', 'CDumper', 'CEmitter', 'CLoader', 
'CParser', 'CSafeDumper', 'CSafeLoader', 'CollectionEndEvent', 
'CollectionNode', 'CollectionStartEvent', 'CommentCheck', 'CommentToken', 
'Constructor', 'DirectiveToken', 'DocumentEndEvent', 'DocumentEndToken', 
'DocumentStartEvent', 'DocumentStartToken', 'Dumper', 'Event', 
'FlowEntryToken', 'FlowMappingEndToken', 'FlowMappingStartToken', 
'FlowSequenceEndToken', 'FlowSequenceStartToken', 'KeyToken', 'Loader', 
'MappingEndEvent', 'MappingNode', 'MappingStartEvent', 'Node', 'NodeEvent', 
'PY3', 'Representer', 'Resolver', 'RoundTripConstructor', 
'RoundTripDumper', 'RoundTripLoader', 'RoundTripRepresenter', 'SHOWLINES', 
'SafeConstructor', 'SafeDumper', 'SafeLoader', 'SafeRepresenter', 
'ScalarEvent', 'ScalarNode', 'ScalarToken', 'SequenceEndEvent', 
'SequenceNode', 'SequenceStartEvent', 'StreamEndEvent', 'StreamEndToken', 
'StreamStartEvent', 'StreamStartToken', 'StringIO', 'TagToken', 'Token', 
'UnsafeLoader', 'UnsafeLoaderWarning', 'ValueToken', 'VersionedResolver', 
'YAML', 'YAMLContextManager', 'YAMLError', 'YAMLObject', 
'YAMLObjectMetaclass', '__builtins__', '__cached__', '__doc__', '__file__', 
'__loader__', '__name__', '__package__', '__path__', '__spec__', 
'__version__', '__with_libyaml__', '_package_data', 'absolute_import', 
'add_constructor', 'add_implicit_resolver', 'add_multi_constructor', 
'add_multi_representer', 'add_path_resolver', 'add_representer', 'anchor', 
'comments', 'compat', 'compose', 'compose_all', 'composer', 'constructor', 
'cyaml', 'division', 'dump', 'dump_all', 'dumper', 'emit', 'emitter', 
'enc', 'enforce', 'error', 'events', 'glob', 'import_module', 'load', 
'load_all', 'loader', 'main', 'nodes', 'nprint', 'os', 'parse', 'parser', 
'print_function', 'reader', 'representer', 'resolver', 'round_trip_dump', 
'round_trip_load', 'round_trip_load_all', 'ruamel', 'safe_dump', 
'safe_dump_all', 'safe_load', 'safe_load_all', 'scalarbool', 'scalarfloat', 
'scalarint', 'scalarstring', 'scan', 'scanner', 'serialize', 
'serialize_all', 'serializer', 'string_types', 'sys', 'timestamp', 
'tokens', 'unicode_literals', 'util', 'version_info', 'warnings', 
'with_metaclass', 'yaml_object'] 
['Xdump_all', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', 
'__enter__', '__eq__', '__exit__', '__format__', '__ge__', 
'__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', 
'__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', 
'__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', 
'__subclasshook__', '__weakref__', '_indent', 'block_seq_indent', 
'compact', 'composer', 'constructor', 'dump', 'dump_all', 'emitter', 
'get_constructor_parser', 'get_serializer_representer_emitter', 'indent', 
'load', 'load_all', 'map', 'official_plug_ins', 'parse', 'parser', 
'reader', 'register_class', 'representer', 'resolver', 'scanner', 'seq', 
'serializer'] 
['__cause__', '__class__', '__context__', '__delattr__', '__dict__', 
'__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', 
'__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', 
'__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', 
'__repr__', '__setattr__', '__setstate__', '__sizeof__', '__str__', 
'__subclasshook__', '__suppress_context__', '__traceback__', '__weakref__', 
'args', 'with_traceback'] 

*Output of the PyInstaller compiled script*:
['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', 
'__name__', '__package__', '__path__', '__spec__', 'anchor', 'comments', 
'compat', 'composer', 'constructor', 'dumper', 'emitter', 'error', 
'events', 'loader', 'main', 'nodes', 'parser', 'reader', 'representer', 
'resolver', 'scalarbool', 'scalarfloat', 'scalarint', 'scalarstring', 
'scanner', 'serializer', 'timestamp', 'tokens', 'util'] 
['Xdump_all', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', 
'__enter__', '__eq__', '__exit__', '__format__', '__ge__', 
'__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', 
'__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', 
'__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', 
'__subclasshook__', '__weakref__', '_indent', 'block_seq_indent', 
'compact', 'composer', 'constructor', 'dump', 'dump_all', 'emitter', 
'get_constructor_parser', 'get_serializer_representer_emitter', 'indent', 
'load', 'load_all', 'map', 'official_plug_ins', 'parse', 'parser', 
'reader', 'register_class', 'representer', 'resolver', 'scanner', 'seq', 
'serializer'] 
['__cause__', '__class__', '__context__', '__delattr__', '__dict__', 
'__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', 
'__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', 
'__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', 
'__repr__', '__setattr__', '__setstate__', '__sizeof__', '__str__', 
'__subclasshook__', '__suppress_context__', '__traceback__', '__weakref__', 
'args', 'with_traceback'] 

If anyone has any ideas on a fix for this issue, or how to improve the 
hook, that would be greatly appreciated :)

-- 
You received this message because you are subscribed to the Google Groups 
"PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pyinstaller/db7b9a3f-5135-4c57-b0b1-0d8ff3ac4bfco%40googlegroups.com.
import ruamel.yaml
from ruamel.yaml.main import YAML
from ruamel.yaml.parser import ParserError

yaml = YAML(typ='safe')
print(dir(ruamel.yaml))
print(dir(YAML))
print(dir(ParserError))

from PyInstaller.utils.hooks import collect_all
import _ruamel_yaml
import ruamel.yaml
from ruamel.yaml import version_info

datas, binaries, hiddenimports = collect_all('ruamel.yaml')

hiddenimports.append('_ruamel_yaml')

Reply via email to