From 1434d97d08a4568659d24eaeef1dd94939f05010 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Eertmans?= Date: Tue, 22 Aug 2023 11:41:46 +0200 Subject: [PATCH 1/2] feat(cli): add TUI with trogon WIP --- manim_slides/__main__.py | 3 ++ poetry.lock | 70 +++++++++++++++++++++++++++++++++++++++- pyproject.toml | 1 + 3 files changed, 73 insertions(+), 1 deletion(-) diff --git a/manim_slides/__main__.py b/manim_slides/__main__.py index 4bc572ee..6b3b83c8 100644 --- a/manim_slides/__main__.py +++ b/manim_slides/__main__.py @@ -3,6 +3,7 @@ import click import requests from click_default_group import DefaultGroup +from trogon import tui from .__version__ import __version__ from .convert import convert @@ -11,6 +12,7 @@ from .wizard import init, wizard +@tui() @click.group(cls=DefaultGroup, default="present", default_if_no_args=True) @click.option( "--notify-outdated-version/--silent", @@ -70,5 +72,6 @@ def cli(notify_outdated_version: bool) -> None: cli.add_command(present) cli.add_command(wizard) + if __name__ == "__main__": cli() diff --git a/poetry.lock b/poetry.lock index 42dee1b1..7f7289f7 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1329,6 +1329,26 @@ files = [ {file = "kiwisolver-1.4.4.tar.gz", hash = "sha256:d41997519fcba4a1e46eb4a2fe31bc12f0ff957b2b81bac28db24744f333e955"}, ] +[[package]] +name = "linkify-it-py" +version = "2.0.2" +description = "Links recognition library with FULL unicode support." +optional = false +python-versions = ">=3.7" +files = [ + {file = "linkify-it-py-2.0.2.tar.gz", hash = "sha256:19f3060727842c254c808e99d465c80c49d2c7306788140987a1a7a29b0d6ad2"}, + {file = "linkify_it_py-2.0.2-py3-none-any.whl", hash = "sha256:a3a24428f6c96f27370d7fe61d2ac0be09017be5190d68d8658233171f1b6541"}, +] + +[package.dependencies] +uc-micro-py = "*" + +[package.extras] +benchmark = ["pytest", "pytest-benchmark"] +dev = ["black", "flake8", "isort", "pre-commit", "pyproject-flake8"] +doc = ["myst-parser", "sphinx", "sphinx-book-theme"] +test = ["coverage", "pytest", "pytest-cov"] + [[package]] name = "lxml" version = "4.9.3" @@ -1626,6 +1646,8 @@ files = [ ] [package.dependencies] +linkify-it-py = {version = ">=1,<3", optional = true, markers = "extra == \"linkify\""} +mdit-py-plugins = {version = "*", optional = true, markers = "extra == \"plugins\""} mdurl = ">=0.1,<1.0" [package.extras] @@ -3856,6 +3878,23 @@ files = [ [package.dependencies] mpmath = ">=0.19" +[[package]] +name = "textual" +version = "0.33.0" +description = "Modern Text User Interface framework" +optional = false +python-versions = ">=3.7,<4.0" +files = [ + {file = "textual-0.33.0-py3-none-any.whl", hash = "sha256:698a093add0fd21c786232bcacde9ff427a9d5dc9ea5deca93437d9453e4ead1"}, + {file = "textual-0.33.0.tar.gz", hash = "sha256:e0a98b1d9c4458c5bb4269c65d0a7f3e926f197411242d2f8faf80183d47a728"}, +] + +[package.dependencies] +importlib-metadata = ">=4.11.3" +markdown-it-py = {version = ">=2.1.0", extras = ["linkify", "plugins"]} +rich = ">=13.3.3" +typing-extensions = ">=4.4.0,<5.0.0" + [[package]] name = "tinycss2" version = "1.2.1" @@ -3940,6 +3979,21 @@ files = [ docs = ["myst-parser", "pydata-sphinx-theme", "sphinx"] test = ["argcomplete (>=2.0)", "pre-commit", "pytest", "pytest-mock"] +[[package]] +name = "trogon" +version = "0.5.0" +description = "Automatically generate a Textual TUI for your Click CLI" +optional = false +python-versions = ">=3.7,<4.0" +files = [ + {file = "trogon-0.5.0-py3-none-any.whl", hash = "sha256:987d2195c1dd2f93c50e555063a9de57edbc5906ce20ee39081343ff194952c1"}, + {file = "trogon-0.5.0.tar.gz", hash = "sha256:61a57f0f1a38227d90601cd020f46960be8e36947b5e56c6932c2e01ecc5042a"}, +] + +[package.dependencies] +click = ">=8.0.0" +textual = ">=0.26.0" + [[package]] name = "typing-extensions" version = "4.7.1" @@ -3951,6 +4005,20 @@ files = [ {file = "typing_extensions-4.7.1.tar.gz", hash = "sha256:b75ddc264f0ba5615db7ba217daeb99701ad295353c45f9e95963337ceeeffb2"}, ] +[[package]] +name = "uc-micro-py" +version = "1.0.2" +description = "Micro subset of unicode data files for linkify-it-py projects." +optional = false +python-versions = ">=3.7" +files = [ + {file = "uc-micro-py-1.0.2.tar.gz", hash = "sha256:30ae2ac9c49f39ac6dce743bd187fcd2b574b16ca095fa74cd9396795c954c54"}, + {file = "uc_micro_py-1.0.2-py3-none-any.whl", hash = "sha256:8c9110c309db9d9e87302e2f4ad2c3152770930d88ab385cd544e7a7e75f3de0"}, +] + +[package.extras] +test = ["coverage", "pytest", "pytest-cov"] + [[package]] name = "urllib3" version = "2.0.4" @@ -4106,4 +4174,4 @@ sphinx-directive = ["docutils", "jinja2", "manim"] [metadata] lock-version = "2.0" python-versions = ">=3.8.1,<3.12" -content-hash = "d538c1ad639ba47b69a6a233553c09d371599310bf04f3772c035f58182cbeba" +content-hash = "878eb9dad0be1f88af4fb1bf61e77e05b667a14532eebb51b499fdc2ef408540" diff --git a/pyproject.toml b/pyproject.toml index 748fb6a1..6adb4228 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -66,6 +66,7 @@ requests = "^2.28.1" rich = "^13.3.2" rtoml = "^0.9.0" tqdm = "^4.64.1" +trogon = "^0.5.0" [tool.poetry.extras] magic = ["manim", "ipython"] From 6e931f263557531de3e3337310af8b0969aeb00a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Eertmans?= Date: Wed, 2 Oct 2024 17:59:17 +0200 Subject: [PATCH 2/2] chore(deps): bump trogon --- pyproject.toml | 1 + uv.lock | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index ea175527..9fdb511c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,6 +32,7 @@ dependencies = [ "rich>=13.3.2", "rtoml>=0.11.0", "tqdm>=4.64.1", + "trogon>=0.6.0", ] description = "Tool for live presentations using manim" dynamic = ["readme", "version"] diff --git a/uv.lock b/uv.lock index 0b8c362e..9cc4fad3 100644 --- a/uv.lock +++ b/uv.lock @@ -1094,6 +1094,18 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/8c/95/4a103776c265d13b3d2cd24fb0494d4e04ea435a8ef97e1b2c026d43250b/kiwisolver-1.4.7-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:0c6c43471bc764fad4bc99c5c2d6d16a676b1abf844ca7c8702bdae92df01ee0", size = 55811 }, ] +[[package]] +name = "linkify-it-py" +version = "2.0.3" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "uc-micro-py" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/2a/ae/bb56c6828e4797ba5a4821eec7c43b8bf40f69cda4d4f5f8c8a2810ec96a/linkify-it-py-2.0.3.tar.gz", hash = "sha256:68cda27e162e9215c17d786649d1da0021a451bdc436ef9e0fa0ba5234b9b048", size = 27946 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/04/1e/b832de447dee8b582cac175871d2f6c3d5077cc56d5575cadba1fd1cccfa/linkify_it_py-2.0.3-py3-none-any.whl", hash = "sha256:6bcbc417b0ac14323382aef5c5192c0075bf8a9d6b41820a2b66371eac6b6d79", size = 19820 }, +] + [[package]] name = "lxml" version = "5.3.0" @@ -1256,6 +1268,7 @@ dependencies = [ { name = "rich" }, { name = "rtoml" }, { name = "tqdm" }, + { name = "trogon" }, ] [package.optional-dependencies] @@ -1392,6 +1405,7 @@ requires-dist = [ { name = "sphinx-copybutton", marker = "extra == 'docs'", specifier = ">=0.5.1" }, { name = "sphinxext-opengraph", marker = "extra == 'docs'", specifier = ">=0.7.5" }, { name = "tqdm", specifier = ">=4.64.1" }, + { name = "trogon", specifier = ">=0.6.0" }, ] [package.metadata.requires-dev] @@ -1518,6 +1532,14 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/42/d7/1ec15b46af6af88f19b8e5ffea08fa375d433c998b8a7639e76935c14f1f/markdown_it_py-3.0.0-py3-none-any.whl", hash = "sha256:355216845c60bd96232cd8d8c40e8f9765cc86f46880e43a8fd22dc1a1a8cab1", size = 87528 }, ] +[package.optional-dependencies] +linkify = [ + { name = "linkify-it-py" }, +] +plugins = [ + { name = "mdit-py-plugins" }, +] + [[package]] name = "markupsafe" version = "2.1.5" @@ -3349,6 +3371,21 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/99/ff/c87e0622b1dadea79d2fb0b25ade9ed98954c9033722eb707053d310d4f3/sympy-1.13.3-py3-none-any.whl", hash = "sha256:54612cf55a62755ee71824ce692986f23c88ffa77207b30c1368eda4a7060f73", size = 6189483 }, ] +[[package]] +name = "textual" +version = "0.81.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "markdown-it-py", extra = ["linkify", "plugins"] }, + { name = "platformdirs" }, + { name = "rich" }, + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/2c/f0/b530868b21d68fd27a8a68f7511ef8573e0d63b359004c50da7b36b6c7b7/textual-0.81.0.tar.gz", hash = "sha256:b438f7e6bb143fdec379170ccc6709a32d273bd998e70179537109263de7c818", size = 1398749 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/1f/a1/491750a84d9d0982f49ed49f1227ee32cf32ef0e287811e154cc79e64827/textual-0.81.0-py3-none-any.whl", hash = "sha256:5f94e3bf185a1693c31f5e2bcbc413c8ed093a53abc96a956c65322d48f9543c", size = 596420 }, +] + [[package]] name = "tinycss2" version = "1.3.0" @@ -3418,6 +3455,19 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/00/c0/8f5d070730d7836adc9c9b6408dec68c6ced86b304a9b26a14df072a6e8c/traitlets-5.14.3-py3-none-any.whl", hash = "sha256:b74e89e397b1ed28cc831db7aea759ba6640cb3de13090ca145426688ff1ac4f", size = 85359 }, ] +[[package]] +name = "trogon" +version = "0.6.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "click" }, + { name = "textual" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/cf/ae/7367acac2194a215b092ba3fccde3b558272702110b8bb9bea164ab4ac42/trogon-0.6.0.tar.gz", hash = "sha256:fd1abfeb7b15d79d6e6cfc9e724aad2a2728812e4713a744d975f133e7ec73a4", size = 22902 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/97/30/33035d5796a3b8b9624997fec7545e3febd2268c7b48df38a715a95cb5e4/trogon-0.6.0-py3-none-any.whl", hash = "sha256:fb5b6c25acd7a0eaba8d2cd32a57f1d80c26413cea737dad7a4eebcda56060e0", size = 26077 }, +] + [[package]] name = "typing-extensions" version = "4.12.2" @@ -3427,6 +3477,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/26/9f/ad63fc0248c5379346306f8668cda6e2e2e9c95e01216d2b8ffd9ff037d0/typing_extensions-4.12.2-py3-none-any.whl", hash = "sha256:04e5ca0351e0f3f85c6853954072df659d0d13fac324d0072316b67d7794700d", size = 37438 }, ] +[[package]] +name = "uc-micro-py" +version = "1.0.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/91/7a/146a99696aee0609e3712f2b44c6274566bc368dfe8375191278045186b8/uc-micro-py-1.0.3.tar.gz", hash = "sha256:d321b92cff673ec58027c04015fcaa8bb1e005478643ff4a500882eaab88c48a", size = 6043 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/37/87/1f677586e8ac487e29672e4b17455758fce261de06a0d086167bb760361a/uc_micro_py-1.0.3-py3-none-any.whl", hash = "sha256:db1dffff340817673d7b466ec86114a9dc0e9d4d9b5ba229d9d60e5c12600cd5", size = 6229 }, +] + [[package]] name = "urllib3" version = "2.2.3"