From 5e9a6f19bd62657fffd62dea07590d138299a942 Mon Sep 17 00:00:00 2001 From: Aaron Guise Date: Fri, 20 Feb 2026 14:17:53 +1300 Subject: [PATCH] =?UTF-8?q?fix:=20add=20=5F=5Fmain=5F=5F.py=20so=20python?= =?UTF-8?q?=20-m=20directdnsonly=20works=20in=20container=20=F0=9F=90=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - directdnsonly/__main__.py: inserts package dir into sys.path before importing main.py (which uses short-form relative imports) then calls main(); works for both `python -m directdnsonly` and the dadns script - pyproject.toml: wire up `dadns` console script entry point --- directdnsonly/__main__.py | 17 +++++++++++++++++ pyproject.toml | 3 +++ 2 files changed, 20 insertions(+) create mode 100644 directdnsonly/__main__.py diff --git a/directdnsonly/__main__.py b/directdnsonly/__main__.py new file mode 100644 index 0000000..7e26a0d --- /dev/null +++ b/directdnsonly/__main__.py @@ -0,0 +1,17 @@ +import os +import sys + + +def run(): + # main.py uses short-form imports (from app.*, from worker) that resolve + # relative to the directdnsonly/ package directory. Insert it into the + # path before importing so `python -m directdnsonly` and the `dadns` + # console script both work without changing main.py. + sys.path.insert(0, os.path.dirname(__file__)) + from main import main + + main() + + +if __name__ == "__main__": + run() diff --git a/pyproject.toml b/pyproject.toml index 462e728..b8f2455 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,6 +20,9 @@ dependencies = [ "requests (>=2.32.0,<3.0.0)", ] +[project.scripts] +dadns = "directdnsonly.__main__:run" + [tool.poetry] package-mode = true