kolibri icon indicating copy to clipboard operation
kolibri copied to clipboard

Clean up duplication left by the platform migration

Open rtibbles opened this issue 4 months ago • 8 comments

❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.

Overview

Co-locating the installer repos into platforms/ made some standalone-era duplication removable. Consolidate the genuinely-shared bits and drop stale pre-migration scaffolding.

Complexity: Low Target branch: develop

Context

  • The Kolibri-version read is reimplemented four ways (debian-server, desktop-app, android, raspberry-pi).
  • build_tools/read_whl_version.py already provides that read but sits unused.
  • android builds Kolibri from the workspace via stage-workspace-tar.
  • desktop-app has no equivalent target; its get-whl fetches a whl from a URL for local dev.
  • platforms/android/README.md still documents pre-migration setup that contradicts its own monorepo section.

Acceptance Criteria

  • [ ] The "read the workspace Kolibri version" step goes through one shared helper across platforms; per-platform version conversions stay separate.
  • [ ] desktop-app has a stage-workspace-whl Makefile target mirroring android's stage-workspace-tar.
  • [ ] The stale clone/venv/get-tar instructions in platforms/android/README.md are removed or reconciled with the monorepo workflow.

AI usage

Claude Code located the duplications across platforms/; I triaged which are the same knowledge vs coincidental and edited the issue.

rtibbles avatar Jul 23 '26 21:07 rtibbles

Scoping this before implementation. AC2 and AC3 are clear and I'll implement them as written:

  • AC2 — add stage-workspace-whl to platforms/desktop-app/Makefile, mirroring android's stage-workspace-tar: run $(MAKE) -C ../.. dist, glob the freshest ../../dist/kolibri-*.whl, stage it into whl/, and hand it to the existing install-whl. (uv build emits both the whl and the sdist tar, so the whl is always there.)
  • AC3 — reconcile platforms/android/README.md: drop the standalone "Initial Setup" clone/uv venv/get-tar steps (lines ~60–98) and the get-tar line in Quick Start, deferring to the existing "Monorepo & Android Studio" section (uv sync --all-packages, stage-workspace-tar).

AC1 needs a decision before I touch it. The helper build_tools/read_whl_version.py reads a whl (pkginfo.Wheel), but only desktop-app has a whl at its version-read point. The four reads are genuinely different artifacts/stages:

Platform Reads version from Artifact Where
desktop-app pkginfo.Installed('kolibri') (Makefile:20) whl → kolibrisrc/ Makefile
android kolibri/VERSION text (app/build.gradle:105-110) extracted tar Gradle (Groovy)
debian-server strip kolibri-…tar.gz filename (platform-debian-server-build_deb.yml:41-42) tar CI workflow
raspberry-pi regex on kolibri_*.deb filename (Makefile:62) .deb Makefile

So "one shared helper" is not a drop-in. Two questions:

Q1 — how should the helper cover non-whl reads? android and debian-server read a tar; the helper reads a whl. Either:

  • (a) generalize read_whl_version.py to read any workspace dist artifact (whl and sdist tar via pkginfo), or
  • (b) keep it whl-only and have each platform read the version from the sibling dist/kolibri-*.whl that uv build always emits, even when it ultimately packages the tar/deb.

I lean (b) — it keeps the helper unchanged ("already provides that read") and gives one source of truth, at the cost of reading a whl you don't package.

Q2 — are android and raspberry-pi in scope?

  • android's read is in Gradle (Groovy), from the tar's VERSION file. Route it through the Python helper (shelling out, as it already does for versionCode), or leave the Gradle read as-is?
  • raspberry-pi reads a .deb filename to name its .img — it never handles a workspace whl/tar. Is this in scope, or does it count as a "per-platform version conversion" that stays separate (matching the AC carve-out)?

My default if unanswered: (b) for Q1; route debian-server (CI) and desktop-app through the helper; leave android's Gradle read and raspberry-pi's .deb read alone. Happy to widen scope if that's the intent.

rtibblesbot avatar Jul 23 '26 23:07 rtibblesbot

The bot has been waiting for a response for 2 hour(s). It will resume automatically when someone replies.

rtibblesbot avatar Jul 24 '26 01:07 rtibblesbot

For 1, I would say a) - we should make it a single Python package that is able to read the version from an arbitrary entity. However, what we can do is standardize it to read from the _version.py file emitted by the setuptools-scm build. Noting that the current Android behaviour to read VERSION is either broken or deprecated!

For 2, they should both be in scope - however I also think that the actual answer for 1 should be based on what works best for each of the platforms. If reading the whl file version is not actually the best path forward, and each one should have its own logic, that's fine - but we should be deferring to the correct artifact as the source of truth. VERSION file is no longer used or created, so it has to read from _version.py at a minimum. The exact mechanism for doing that is whatever is appropriate for the platform - but if it can be unified across platforms, then we should do so.

rtibbles avatar Jul 29 '26 21:07 rtibbles

Thanks — that resolves it. Confirming the resolved scope before implementation.

One factual correction: kolibri/VERSION isn't gone yet — the root Makefile writeversion target (a dist prerequisite) still generates it as a plaintext copy of _version.py, it ships in the sdist (MANIFEST.in:6), and android is its sole remaining reader (app/build.gradle:95,105). So it's deprecated-in-intent but live-in-fact. _version.py (setuptools-scm, pyproject.toml:168) is the real source of truth — kolibri.__version__ reads only it. This makes the VERSION retirement a concrete deletion step, not a no-op.

AC1 — shared helper, standardized on _version.py:

  • Generalize build_tools/read_whl_version.py into one helper that reads the version from kolibri/_version.py, accepting an extracted tree, a wheel, or an sdist. Update the existing Makefile:227 pex consumer to the new interface.
  • android: read tar/extracted/kolibri/_version.py via the helper (shelling out to Python, as it already does for versionCode), replacing the VERSION-file read. The sdist android extracts contains _version.py, so this is a clean swap.
  • desktop-app: read _version.py from the staged whl via the helper, replacing pkginfo.Installed('kolibri').
  • debian-server: read via the helper (workspace/artifact) instead of the CI tar-filename strip; PEP 440 → Debian conversion in generate_changelog.py stays separate.
  • raspberry-pi: keep its .deb-filename parse. Its correct artifact is the .deb it packages (the Debian-converted version — a per-platform conversion that "stays separate" per the AC); no _version.py exists at Pi-image build. Considered, deliberately not forced through the helper — matching your "defer to the correct artifact" steer.
  • VERSION retirement: once android is off it, kolibri/VERSION has no readers → remove writeversion (target + dist dep + rm -f clean line) and include kolibri/VERSION from MANIFEST.in. Aligns the tree with "VERSION is deprecated." If you'd rather keep VERSION for now, android's switch stands alone and this is the only separable sub-step — shout if you want it left in.

AC2 — stage-workspace-whl: mirrors stage-workspace-tar ($(MAKE) -C ../.. dist → glob freshest ../../dist/kolibri-*.whl → stage into whl/ → install-whl).

AC3 — android README: drop the standalone "Initial Setup" (clone/uv venv/get-tar) and the get-tar Quick Start step, deferring to the "Monorepo & Android Studio" section; keep the SDK/JDK/emulator setup.

Proceeding on this basis.

rtibblesbot avatar Jul 29 '26 23:07 rtibblesbot

Correction to my last comment: kolibri/VERSION cannot be retired. I said android was its sole remaining reader. That was true only of this repo — I hadn't checked the external installers, which consume the sdist we publish:

Reader Called from Effect of deleting kolibri/VERSION
[email protected] Makefile:18-21 (tar -zxvf … kolibri/VERSION) pr_build_kolibri.yml:24-30 (deb) + release path Every PR red — deb fails, taking zip, pi_smoke_test, server_smoke_test with it
[email protected] app/build.gradle:93,103 release_kolibri.yml:122 (apk) Release APK breaks — silent until a release is cut

The Kolibri .deb still comes from the external Debian installer (platforms/debian-server packages kolibri-server, a different package), and the release APK still comes from the external android repo even though platforms/android/ builds the PR one. So retirement is blocked on those two consumers, not on anything in this issue — the release-path half is #15072.

Revised plan: writeversion, MANIFEST.in:6 and the .gitignore entry all stay, with a comment at the generator naming the two external readers so this dead end isn't re-walked. AC1/AC2/AC3 are unaffected — android still moves to _version.py, it just isn't the last reader of the file.

One consequence worth knowing: no released sdist ships kolibri/_version.py (v0.19.5 built from setup.py with version=kolibri.__version__; the setuptools-scm version_file commit is in no release tag). After the android switch, make get-tar tar=<release URL> + ./gradlew fails rather than building. CI is unaffected (it always builds from the same commit) and AC3 removes the README's get-tar recommendation, so the fix is a directive error message pointing at make stage-workspace-tar.

rtibblesbot avatar Jul 29 '26 23:07 rtibblesbot

Plan: Route every platform's "read the workspace Kolibri version" step through one shared helper standardized on kolibri/_version.py, add desktop-app's missing stage-workspace-whl target, and strip pre-migration setup from the android README.

  • [x] Generalized version-read helper
  • [x] android reads _version.py instead of VERSION
  • [x] Pin why kolibri/VERSION survives
  • [x] desktop-app version read via the helper
  • [x] desktop-app stage-workspace-whl (AC2)
  • [x] debian-server CI reads the version via the helper
  • [x] android README reconciliation (AC3)

All seven landed in #15106.

Acceptance criteria — ticked here rather than in the issue body, because this account lacks UpdateIssue permission on the body:

  • [x] AC1 — one shared helper for the version read; per-platform conversions stay separate. build_tools/read_kolibri_version.py is the single reader of kolibri/_version.py; android (app/build.gradle:121), desktop-app (Makefile:23), debian-server CI (platform-debian-server-build_deb.yml:33) and the root pex target (Makefile:232) all call it. PEP 440 → Debian (generate_changelog.py) and Android versionCode are untouched. raspberry-pi is deliberately excluded — it parses the .deb filename it packages, which is the correct artifact at that stage (no _version.py exists at Pi-image build), matching your "defer to the correct artifact" steer and the AC's own carve-out for per-platform conversions.
  • [x] AC2 — platforms/desktop-app/Makefile:86 stage-workspace-whl, mirroring android's stage-workspace-tar.
  • [x] AC3 — platforms/android/README.md: the standalone clone/uv venv/get-tar Initial Setup is gone and Quick Start prescribes the monorepo commands. grep -n "get-tar\|kolibri-installer-android\|uv venv\|--extra build\|0\.17\.0" platforms/android/README.md returns nothing.

Not delivered as scoped: the kolibri/VERSION retirement I proposed on 2026-07-29 and then withdrew. Two external installer repos read that file out of the sdist we publish ([email protected], [email protected]), both called from this repo's workflows, so deleting it reddens the PR deb job. Makefile:204 now carries a comment naming them; the PR body has the evidence.


@rtibblesbot's comments are generated by an LLM, and should be evaluated accordingly

How was this generated?
  • Implemented code following the pre-approved plan using test-driven development (red-green-refactor)
  • Ran the project's full test suite and linter before committing
  • For UI changes: captured live screenshots to verify rendering
  • For backend changes: verified with example API/CLI output

rtibblesbot avatar Jul 30 '26 00:07 rtibblesbot

The bot has been waiting for a response for 2 hour(s). It will resume automatically when someone replies.

rtibblesbot avatar Jul 30 '26 08:07 rtibblesbot

The bot has been waiting for a response for 2 hour(s). It will resume automatically when someone replies.

rtibblesbot avatar Aug 04 '26 09:08 rtibblesbot