From 3b62a5f38f24c501fc68cf08b03d2cab85c91125 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Sun, 1 Mar 2026 16:18:22 -0800 Subject: [PATCH] add imgui: Dear ImGui 1.92.7 (docking) + ImPlot 0.18 + rlImGui MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Shim package — sources downloaded from GitHub Release at install time. Co-Authored-By: Claude Opus 4.6 --- imgui/imgui/__init__.py | 10 ++++++ imgui/pyproject.toml | 20 +++++++++++ imgui/setup.py | 74 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 104 insertions(+) create mode 100644 imgui/imgui/__init__.py create mode 100644 imgui/pyproject.toml create mode 100644 imgui/setup.py diff --git a/imgui/imgui/__init__.py b/imgui/imgui/__init__.py new file mode 100644 index 0000000..ae698cd --- /dev/null +++ b/imgui/imgui/__init__.py @@ -0,0 +1,10 @@ +import os + +DIR = os.path.join(os.path.dirname(__file__), "install") +INCLUDE_DIR = os.path.join(DIR, "include") +SRC_DIR = os.path.join(DIR, "src") + + +def smoketest(): + assert os.path.isfile(os.path.join(INCLUDE_DIR, "imgui.h")), "imgui.h not found" + assert os.path.isfile(os.path.join(SRC_DIR, "imgui.cpp")), "imgui.cpp not found" diff --git a/imgui/pyproject.toml b/imgui/pyproject.toml new file mode 100644 index 0000000..7726bc9 --- /dev/null +++ b/imgui/pyproject.toml @@ -0,0 +1,20 @@ +[build-system] +requires = ["setuptools>=64", "wheel", 'tomli; python_version < "3.11"'] +build-backend = "setuptools.build_meta" + +[project] +name = "imgui" +version = "1.92.7" +description = "Dear ImGui + ImPlot + rlImGui (source distribution)" +requires-python = ">=3.8" + +[tool.setuptools.packages.find] +include = ["imgui*"] + +[tool.setuptools.package-data] +imgui = ["install/**/*"] + +[tool.shim] +repo_url = "https://github.com/commaai/dependencies" +tag = "imgui/v1.92.7" +datadir = "install" diff --git a/imgui/setup.py b/imgui/setup.py new file mode 100644 index 0000000..d631f00 --- /dev/null +++ b/imgui/setup.py @@ -0,0 +1,74 @@ +"""Shim setup.py: downloads pre-built wheels from GitHub Releases at install time.""" +import os +import platform +import zipfile +from io import BytesIO +from urllib.request import urlopen + +try: + import tomllib +except ImportError: + import tomli as tomllib + +from setuptools import setup +from setuptools.command.build_py import build_py + +_HERE = os.path.dirname(os.path.abspath(__file__)) +with open(os.path.join(_HERE, "pyproject.toml"), "rb") as _f: + _cfg = tomllib.load(_f) + +REPO_URL = _cfg["tool"]["shim"]["repo_url"] +TAG = _cfg["tool"]["shim"]["tag"] +DATADIR = _cfg["tool"]["shim"]["datadir"] +VERSION = _cfg["project"]["version"] +MODULE = _cfg["project"]["name"].replace("-", "_") + +PLATFORM_MAP = { + ("Linux", "x86_64"): "linux_x86_64", + ("Linux", "aarch64"): "linux_aarch64", + ("Darwin", "arm64"): "macosx_11_0_arm64", +} + + +class InstallPrebuilt(build_py): + def run(self): + module_dir = os.path.join(_HERE, MODULE) + data_dir = os.path.join(module_dir, DATADIR) + + if not os.path.exists(os.path.join(data_dir, "include")): + key = (platform.system(), platform.machine()) + plat = PLATFORM_MAP.get(key) + if plat is None: + raise RuntimeError(f"unsupported platform: {key}") + + whl_name = f"{MODULE}-{VERSION}-py3-none-{plat}.whl" + url = f"{REPO_URL}/releases/download/{TAG}/{whl_name}" + + print(f"Downloading {url} ...") + raw = urlopen(url).read() + + print(f"Extracting {DATADIR} ...") + with zipfile.ZipFile(BytesIO(raw)) as zf: + prefix = f"{MODULE}/{DATADIR}/" + alt_prefix = f"{MODULE}-{VERSION}.data/purelib/{MODULE}/{DATADIR}/" + for info in zf.infolist(): + for p in (prefix, alt_prefix): + if info.filename.startswith(p): + rel = info.filename[len(p):] + if not rel: + continue + dest = os.path.join(data_dir, rel) + if info.is_dir(): + os.makedirs(dest, exist_ok=True) + else: + os.makedirs(os.path.dirname(dest), exist_ok=True) + with open(dest, "wb") as f: + f.write(zf.read(info)) + if info.external_attr >> 16 & 0o111: + os.chmod(dest, 0o755) + break + + super().run() + + +setup(cmdclass={"build_py": InstallPrebuilt})