From d6790448b1a37dfb48fd38149700a863f33b1c85 Mon Sep 17 00:00:00 2001 From: zmoon Date: Tue, 16 Dec 2025 17:41:06 -0600 Subject: [PATCH 01/16] Use uv dependency groups keeping flit_core as build backend for now, since uv_build seems to be missing some things, like dynamic version --- .gitignore | 2 ++ pyproject.toml | 14 +++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index e082d48..550f1cd 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,8 @@ data/*.png docs/api/ panel/app.html +uv.lock + # Byte-compiled / optimized / DLL files __pycache__/ diff --git a/pyproject.toml b/pyproject.toml index 988d33d..93029e2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,6 +23,12 @@ Source = "https://github.com/zmoon/stringcalc" Documentation = "https://stringcalc.readthedocs.io" [project.optional-dependencies] +cli = [ + "rich", + "typer", +] + +[dependency-groups] test = [ "mypy", "pandas-stubs", @@ -32,10 +38,6 @@ test = [ dev = [ "ipython", ] -cli = [ - "rich", - "typer", -] doc = [ "matplotlib", "myst-nb", @@ -49,10 +51,12 @@ doc = [ [project.scripts] stringcalc = "stringcalc.cli:app" +[tool.uv] +default-groups = "all" + [tool.flit.sdist] exclude = ["data/", ".github/", "panel/", ".gitignore"] - [tool.black] line-length = 100 From 2001b235079e9c1d5027fadddb3272f07d362bd3 Mon Sep 17 00:00:00 2001 From: zmoon Date: Tue, 16 Dec 2025 17:44:06 -0600 Subject: [PATCH 02/16] uv doesn't like `~=` without micro --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 93029e2..6f8b9e8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ readme = "README.md" license = {file = "LICENSE"} classifiers = ["License :: OSI Approved :: MIT License"] dynamic = ["version", "description"] -requires-python = "~=3.10" +requires-python = ">=3.10,<4" dependencies = [ "numpy >=1.21", "pandas", From 8845bc6c927eba7cc34f9067cb60135811202e36 Mon Sep 17 00:00:00 2001 From: zmoon Date: Tue, 16 Dec 2025 17:52:25 -0600 Subject: [PATCH 03/16] Panel via uv --- panel/README.md | 10 ++-------- pyproject.toml | 5 +++++ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/panel/README.md b/panel/README.md index 7288c69..682aa0f 100644 --- a/panel/README.md +++ b/panel/README.md @@ -1,14 +1,8 @@ -Conda env setup for development: - - conda env create -f environment.yml - conda activate stringcalc-panel - pip install -e ../ --no-deps - For development: - panel serve --autoreload --show app.py + uv run panel serve --autoreload --show app.py Create deployable HTML file (first set env var `PYTHONUTF8` to `1` for Windows): - panel convert app.py --to pyodide + uv run panel convert app.py --to pyodide diff --git a/pyproject.toml b/pyproject.toml index 6f8b9e8..cfb2aa5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -47,6 +47,11 @@ doc = [ "sphinx-click", "sphinx-copybutton", ] +panel = [ + "hvplot", + "panel ==1.*", + "watchfiles", +] [project.scripts] stringcalc = "stringcalc.cli:app" From 0dc84ad70ecc08627945beeeee686ae2f3074a85 Mon Sep 17 00:00:00 2001 From: zmoon Date: Tue, 16 Dec 2025 18:29:29 -0600 Subject: [PATCH 04/16] Build Panel app with uv for docs build --- .readthedocs.yaml | 24 ++++++++++++++++-------- README.md | 26 ++++++++++++++++++++++++++ docs/_static/panel/.gitignore | 2 ++ docs/conf.py | 2 ++ docs/panel.rst | 2 +- pyproject.toml | 3 --- 6 files changed, 47 insertions(+), 12 deletions(-) create mode 100644 docs/_static/panel/.gitignore diff --git a/.readthedocs.yaml b/.readthedocs.yaml index ce5d21e..01a82aa 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -4,14 +4,22 @@ build: os: ubuntu-lts-latest tools: python: "3.13" - -python: - install: - - method: pip - path: . - extra_requirements: - - doc - - cli + jobs: + pre_create_environment: + - asdf plugin add uv + - asdf install uv latest + - asdf global uv latest + create_environment: + - uv venv "${READTHEDOCS_VIRTUALENV_PATH}" + install: + - UV_PROJECT_ENVIRONMENT="${READTHEDOCS_VIRTUALENV_PATH}" + uv sync --frozen + --group doc + --group panel + --extra cli + pre_build: + - UV_PROJECT_ENVIRONMENT="${READTHEDOCS_VIRTUALENV_PATH}" + uv run panel convert panel/app.py --to pyodide --out docs/_static/panel/ sphinx: configuration: docs/conf.py diff --git a/README.md b/README.md index fee1fd8..4094cd9 100644 --- a/README.md +++ b/README.md @@ -12,3 +12,29 @@ stringcalc gauge --suggest -T 17 -L 23 -P G2 -P D3 -P A3 -P E4 -N 6 --type DA:LE ``` CLI gauge suggestion output for 23" TB for D'Addario loop-end nickel-wound strings + +## Development + +Using [uv](https://docs.astral.sh/uv/), prepare the venv: + +``` +uv sync --all-groups --all-extras +``` + +Run the tests: + +``` +uv run pytest +``` + +Build the Panel app: + +``` +uv run panel convert panel/app.py --to pyodide --out docs/_static/panel/ +``` + +Build the docs: + +``` +uv run sphinx-build docs docs/_build/html +``` diff --git a/docs/_static/panel/.gitignore b/docs/_static/panel/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/docs/_static/panel/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/docs/conf.py b/docs/conf.py index 0545171..0d56f19 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -54,6 +54,8 @@ """, } +html_static_path = ["_static"] + napoleon_google_docstring = False napoleon_numpy_docstring = True napoleon_preprocess_types = True diff --git a/docs/panel.rst b/docs/panel.rst index d1a4335..945c521 100644 --- a/docs/panel.rst +++ b/docs/panel.rst @@ -9,7 +9,7 @@ Panel app .. raw:: html