"""Make bundled third-party libraries importable without pip.

End users may not have pip available in their QGIS Python. To keep the plugin
self-contained, the pure-Python dependencies (pyserial, pyais) are vendored into
the ``libs/`` folder next to this file. Calling :func:`setup` puts that folder
on ``sys.path`` so a plain ``import serial`` / ``import pyais`` resolves to the
bundled copies.

Idempotent and safe to call multiple times. If ``libs/`` is empty (not yet
populated), this is a harmless no-op and the plugin falls back to any
system-installed copies, degrading gracefully if there are none.
"""
import os
import sys

_LIBS_DIR = os.path.join(os.path.dirname(__file__), "libs")


def setup():
    """Prepend the bundled libs/ folder to sys.path (once)."""
    if os.path.isdir(_LIBS_DIR) and _LIBS_DIR not in sys.path:
        sys.path.insert(0, _LIBS_DIR)
