def _dlopen(ffi, *names, allow_fail=False):
    """Try various names for the same library, for different platforms."""
    if os.name == 'nt':
        flags = 0x00001000  # LOAD_LIBRARY_SEARCH_DEFAULT_DIRS
    else:
        flags = ffi.RTLD_NOW  # default
    for name in names:
        with suppress(OSError):
            return ffi.dlopen(name, flags)
    if allow_fail:
        return
    # Re-raise the exception.
    print(
        '\n-----\n\n'
        'WeasyPrint could not import some external libraries. Please '
        'carefully follow the installation steps before reporting an issue:\n'
        'https://doc.courtbouillon.org/weasyprint/stable/'
        'first_steps.html#installation\n'
        'https://doc.courtbouillon.org/weasyprint/stable/'
        'first_steps.html#troubleshooting',
        '\n\n-----\n')  # pragma: no cover
    return ffi.dlopen(names[0], flags)  # pragma: no cover
Try various names for the same library, for different platforms.
weasyprint/text/ffi.py