From cb921f11317b9a4a9d0fa064626da2c1663b5960 Mon Sep 17 00:00:00 2001 From: Cort Buffington Date: Fri, 29 Aug 2025 18:32:35 -0500 Subject: [PATCH] fixing imports --- hblink4/hblink.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/hblink4/hblink.py b/hblink4/hblink.py index 0e92ad3..59064f1 100644 --- a/hblink4/hblink.py +++ b/hblink4/hblink.py @@ -25,11 +25,23 @@ from twisted.internet.protocol import DatagramProtocol CONFIG: Dict[str, Any] = {} LOGGER = logging.getLogger(__name__) -from .constants import ( - RPTA, RPTL, RPTK, RPTC, RPTCL, RPTPING, - DMRD, MSTNAK, MSTPONG, RPTACK -) -from .access_control import RepeaterMatcher +import os +import sys + +# Try package-relative imports first, fall back to direct imports +try: + from .constants import ( + RPTA, RPTL, RPTK, RPTC, RPTCL, RPTPING, + DMRD, MSTNAK, MSTPONG, RPTACK + ) + from .access_control import RepeaterMatcher +except ImportError: + sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) + from constants import ( + RPTA, RPTL, RPTK, RPTC, RPTCL, RPTPING, + DMRD, MSTNAK, MSTPONG, RPTACK + ) + from access_control import RepeaterMatcher # Type definitions PeerAddress = Tuple[str, int]