xml2rfc should not break on weasyprint if that isn't actually needed
Describe the issue
After something randomly changed in my Python environment:
Traceback (most recent call last):
File "/Users/cabo/bin/xml2rfc", line 5, in <module>
from xml2rfc.run import main
File "/Users/cabo/lib/python3.10/site-packages/xml2rfc/__init__.py", line 38, in <module>
from weasyprint.text.ffi import pango
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1002, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 945, in _find_spec
File "<frozen importlib._bootstrap_external>", line 1439, in find_spec
File "<frozen importlib._bootstrap_external>", line 1405, in _get_spec
File "<frozen importlib._bootstrap_external>", line 1255, in __iter__
File "<frozen importlib._bootstrap_external>", line 1242, in _recalculate
File "<frozen importlib._bootstrap_external>", line 1238, in _get_parent_path
KeyError: 'weasyprint'
I did not try to actually generate PDF, so xml2rfc should not depend on that loading properly.
Code of Conduct
- [X] I agree to follow the IETF's Code of Conduct
If you still have this environment, can you provide the Python version, xml2rfc version and the WeasyPrint version? Because I could not recreate this error with different WeasyPrint / xml2rfc combinations.
xml2rfc already checks for ImportError, OSError and AttributeError.
Maybe we can add KeyError to the list or swallow all Exceptions.
The error occurred when there was no working WeasyPrint installed (there may have been remnants of one). I have since fixed the problem that prevented installing WeasyPrint on that machine, so I don't have an easy way to reproduce.
Python version must have been python3.10 (see messages above).
Thank you.
This looks like an error occurred due to a Python environment configuration issue.
There's already logic guarding against not having WeasyPrint or an older version of WeasyPrint.
So xml2rfc will not break if WeasyPrint is not installed.