From bd53496db5f1f454e8fdf3b7335b239c694b1cff Mon Sep 17 00:00:00 2001 From: Viet-Anh Nguyen Date: Sat, 25 Apr 2026 11:08:01 +0700 Subject: [PATCH] chore: post-v0.4.36 cleanup - Delete setup.py. The shim that used to switch the package name to anylabeling-gpu is silently rejected by PEP 621 (pyproject.toml's [project].name is static). After the GPU publish workflow started sed-rewriting pyproject.toml directly in #232, the shim is dead code. Verified: python -m build produces identical metadata before and after deletion. setuptools.build_meta reads pyproject.toml without needing setup.py. - README: bump 'Python 3.10+' to 'Python 3.11+' to match requires-python in pyproject.toml. pip refuses to install on 3.10 today, so the README was actively misleading. - release.yml: flip the action-gh-release defaults so a tag push produces a published, non-prerelease, latest-marked release on its own. Previously every tag landed as a draft prerelease and needed a manual gh release edit (we did this for v0.4.36 today). - CLAUDE.md: the resource-script section described the broken pre-#232 state (pyrcc5/pyrcc6 calls). Replace with the post-fix story (pyside6-rcc + pyside6-lrelease with PyQt6 import rewrite). --- .github/workflows/release.yml | 6 ++--- CLAUDE.md | 19 +++++++--------- README.md | 2 +- setup.py | 42 ----------------------------------- 4 files changed, 12 insertions(+), 57 deletions(-) delete mode 100644 setup.py diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7850560..0dcefaf 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -49,10 +49,10 @@ jobs: uses: softprops/action-gh-release@v2 with: body: ${{steps.github_release.outputs.changelog}} - draft: true - prerelease: true + draft: false + prerelease: false tag_name: ${{ github.ref_name }} - make_latest: 'false' + make_latest: 'true' fail_on_unmatched_files: false build: diff --git a/CLAUDE.md b/CLAUDE.md index 68f2c65..701af67 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -119,17 +119,14 @@ through conda. The macOS extra is `[macos]` (currently `coremltools==8.3.0`). - `anylabeling/resources/resources.qrc` (XML) compiles to `resources.py`. - `anylabeling/resources/translations/{en_US,vi_VN,zh_CN}.{ts,qm}`. -- `scripts/generate_languages.py` extracts translatable strings into `.ts` - files and runs `pyuic6` on `.ui` files. -- `scripts/compile_languages.py` calls `lrelease` to produce `.qm` files, - and then `pyrcc5` to rebuild `resources.py`. - -Note: the project migrated from PyQt5 to PyQt6 (commit `9735fe8`), but -`scripts/compile_languages.py` still calls `pyrcc5`. PyQt6 does not ship a -`pyrcc6`; one common workaround is to keep `pyrcc5` from a PyQt5-tools -sideload, or vendor the resource bytes. `generate_languages.py` already -references `pyrcc6`. Treat this script pair as inconsistent and fix -deliberately when touching it. +- `scripts/compile_languages.py` rebuilds `.qm` files and `resources.py` + from existing `.ts` files. Use after editing translations or icons. +- `scripts/generate_languages.py` does the full extract: runs `pyuic6` on + `.ui` files, `pylupdate6` to refresh `.ts`, then the compile step. +- Both shell out to `pyside6-rcc` and `pyside6-lrelease` (PyQt6 dropped + the standalone `pyrcc` in Qt6) and post-rewrite `from PySide6` to + `from PyQt6` so the generated module uses the runtime's Qt binding. + `PySide6-Essentials` is in the `[dev]` extras for this purpose only. ### Tests diff --git a/README.md b/README.md index dd04215..31659fa 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ All models are downloaded automatically on first use from Hugging Face. ### Install from Pypi -- Requirements: Python 3.10+. Recommended: Python 3.12. +- Requirements: Python 3.11+. Recommended: Python 3.12. - Recommended: [Miniconda/Anaconda](https://docs.conda.io/en/latest/miniconda.html). - Create environment: diff --git a/setup.py b/setup.py deleted file mode 100644 index 1895b3e..0000000 --- a/setup.py +++ /dev/null @@ -1,42 +0,0 @@ -""" -Minimal setup.py shim. - -All static metadata lives in pyproject.toml (PEP 621). -This file only exists to handle the one dynamic behaviour that cannot be -expressed in static TOML: switching the package name to 'anylabeling-gpu' -and replacing onnxruntime with onnxruntime-gpu when __preferred_device__ -is set to 'GPU' in anylabeling/app_info.py. -""" - -import platform -import re - -from setuptools import setup - - -def _read_app_info(key): - with open("anylabeling/app_info.py", encoding="utf-8") as f: - content = f.read() - match = re.search(rf"""^{key} = ['"]([^'"]*)['"]""", content, re.M) - if not match: - raise RuntimeError(f"anylabeling/app_info.py doesn't contain {key}") - return match.group(1) - - -preferred_device = _read_app_info("__preferred_device__") -is_gpu = preferred_device == "GPU" and platform.system() != "Darwin" - -# Only override what pyproject.toml cannot express dynamically. -# setuptools merges these kwargs with pyproject.toml metadata. -if is_gpu: - setup( - name="anylabeling-gpu", - install_requires=[ - # swap CPU onnxruntime for the GPU build - "onnxruntime-gpu>=1.20.0", - ], - ) - print("Building AnyLabeling with GPU support") -else: - setup() # everything comes from pyproject.toml - print("Building AnyLabeling without GPU support (CPU)")