From 65674ad81782247c7baeb5a224845ada0aaea8f6 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Sun, 1 Mar 2026 16:40:46 -0800 Subject: [PATCH] add imgui package (#42) --- imgui/build.sh | 63 +++++++++++++++++++++++++++++++++++++++++ imgui/imgui/__init__.py | 10 +++++++ imgui/pyproject.toml | 15 ++++++++++ imgui/setup.py | 61 +++++++++++++++++++++++++++++++++++++++ pyproject.toml | 1 + 5 files changed, 150 insertions(+) create mode 100755 imgui/build.sh create mode 100644 imgui/imgui/__init__.py create mode 100644 imgui/pyproject.toml create mode 100644 imgui/setup.py diff --git a/imgui/build.sh b/imgui/build.sh new file mode 100755 index 0000000..806fd1d --- /dev/null +++ b/imgui/build.sh @@ -0,0 +1,63 @@ +#!/usr/bin/env bash +set -e + +DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)" +cd "$DIR" + +INSTALL_DIR="$DIR/imgui/install" + +# Idempotent: skip if already present +if [ -f "$INSTALL_DIR/include/imgui.h" ]; then + echo "imgui already present, skipping download." + exit 0 +fi + +# Dear ImGui (docking branch) +IMGUI_VERSION="1.92.7" +IMGUI_COMMIT="934c6a5f5ef2355d6df25395d555cb71f790c4e9" +IMGUI_URL="https://github.com/ocornut/imgui/archive/${IMGUI_COMMIT}.tar.gz" + +# ImPlot (master) +IMPLOT_COMMIT="93c801b4bb801c5c11031d880b6af1d1f70bd79d" +IMPLOT_URL="https://github.com/epezent/implot/archive/${IMPLOT_COMMIT}.tar.gz" + +# rlImGui (main) +RLIMGUI_COMMIT="286e11acd6c785004c9550c7ed3762add2ae3d47" +RLIMGUI_URL="https://github.com/raylib-extras/rlImGui/archive/${RLIMGUI_COMMIT}.tar.gz" + +rm -rf "$INSTALL_DIR" +mkdir -p "$INSTALL_DIR/include/extras" "$INSTALL_DIR/src" + +TMPDIR="$(mktemp -d)" +trap 'rm -rf "$TMPDIR"' EXIT + +echo "Downloading Dear ImGui ${IMGUI_VERSION} (docking) ..." +curl -fSL -o "$TMPDIR/imgui.tar.gz" "$IMGUI_URL" +mkdir -p "$TMPDIR/imgui" +tar --strip-components=1 -xzf "$TMPDIR/imgui.tar.gz" -C "$TMPDIR/imgui" +cp "$TMPDIR/imgui/imgui.h" "$TMPDIR/imgui/imgui_internal.h" "$TMPDIR/imgui/imconfig.h" \ + "$TMPDIR/imgui/imstb_rectpack.h" "$TMPDIR/imgui/imstb_textedit.h" "$TMPDIR/imgui/imstb_truetype.h" \ + "$INSTALL_DIR/include/" +cp "$TMPDIR/imgui/imgui.cpp" "$TMPDIR/imgui/imgui_draw.cpp" "$TMPDIR/imgui/imgui_tables.cpp" \ + "$TMPDIR/imgui/imgui_widgets.cpp" "$TMPDIR/imgui/imgui_demo.cpp" \ + "$INSTALL_DIR/src/" + +echo "Downloading ImPlot ..." +curl -fSL -o "$TMPDIR/implot.tar.gz" "$IMPLOT_URL" +mkdir -p "$TMPDIR/implot" +tar --strip-components=1 -xzf "$TMPDIR/implot.tar.gz" -C "$TMPDIR/implot" +cp "$TMPDIR/implot/implot.h" "$TMPDIR/implot/implot_internal.h" "$INSTALL_DIR/include/" +cp "$TMPDIR/implot/implot.cpp" "$TMPDIR/implot/implot_items.cpp" "$INSTALL_DIR/src/" + +echo "Downloading rlImGui ..." +curl -fSL -o "$TMPDIR/rlimgui.tar.gz" "$RLIMGUI_URL" +mkdir -p "$TMPDIR/rlimgui" +tar --strip-components=1 -xzf "$TMPDIR/rlimgui.tar.gz" -C "$TMPDIR/rlimgui" +cp "$TMPDIR/rlimgui/rlImGui.h" "$TMPDIR/rlimgui/rlImGuiColors.h" "$TMPDIR/rlimgui/imgui_impl_raylib.h" \ + "$INSTALL_DIR/include/" +cp "$TMPDIR/rlimgui/extras/FA6FreeSolidFontData.h" "$TMPDIR/rlimgui/extras/IconsFontAwesome6.h" \ + "$INSTALL_DIR/include/extras/" +cp "$TMPDIR/rlimgui/rlImGui.cpp" "$INSTALL_DIR/src/" + +echo "Installed imgui to $INSTALL_DIR" +du -sh "$INSTALL_DIR" 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..22eeff7 --- /dev/null +++ b/imgui/pyproject.toml @@ -0,0 +1,15 @@ +[build-system] +requires = ["setuptools>=64", "wheel"] +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/**/*"] diff --git a/imgui/setup.py b/imgui/setup.py new file mode 100644 index 0000000..698d225 --- /dev/null +++ b/imgui/setup.py @@ -0,0 +1,61 @@ +import os +import platform +import subprocess + +from setuptools.command.build_py import build_py + +try: + from wheel.bdist_wheel import bdist_wheel +except ImportError: + bdist_wheel = None + + +class BuildImgui(build_py): + """Run build.sh to download imgui sources before collecting package data.""" + + def run(self): + pkg_dir = os.path.dirname(os.path.abspath(__file__)) + marker = os.path.join(pkg_dir, "imgui", "install", "include", "imgui.h") + + if not os.path.isfile(marker): + build_script = os.path.join(pkg_dir, "build.sh") + subprocess.check_call(["bash", build_script], cwd=pkg_dir) + + super().run() + + +cmdclass = {"build_py": BuildImgui} + +if bdist_wheel is not None: + + class PlatformWheel(bdist_wheel): + """Produce a platform-specific, Python-version-agnostic wheel.""" + + def finalize_options(self): + super().finalize_options() + self.root_is_pure = False + + def get_tag(self): + system = platform.system() + machine = platform.machine() + + if system == "Linux": + plat = f"linux_{machine}" + elif system == "Darwin": + plat = "macosx_11_0_arm64" + else: + plat = f"{system.lower()}_{machine}" + + return "py3", "none", plat + + cmdclass["bdist_wheel"] = PlatformWheel + + +def setup(): + from setuptools import setup as _setup + + _setup(cmdclass=cmdclass) + + +if __name__ == "__main__": + setup() diff --git a/pyproject.toml b/pyproject.toml index 5188379..0a06850 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,6 +7,7 @@ members = [ "ffmpeg", "gcc-arm-none-eabi", "git-lfs", + "imgui", "json11", "libjpeg", "libyuv",