Skip to content

feat(onboarding): managed project-local .venv via uv with a correct Python interpreter #57

@db-tycoon-stephen

Description

@db-tycoon-stephen

Problem

New users repeatedly get stuck on Python-environment setup before tycoon ever runs. Concrete case: a beta tester's machine defaulted to Python 3.14 (no dbt-core/dbt-duckdb wheels), so tycoon data transform run broke (#55). The v0.1.8 requires-python = ">=3.12,<3.14" cap only converts that into an install-time resolver error and assumes the user already uses uv. And tycoon doctor never checks the interpreter, so the failure is invisible until a dbt command fails — far from its cause.

Root cause: tycoon inherits whatever python3/pip the user happens to have, instead of owning the interpreter choice.

Approach — decided: Option A, a single project-local env

tycoon manages a project-local .venv/ containing tycoon + dbt + dlt + duckdb, created with a pinned, compatible interpreter via uv. tycoon already assumes a single env (in-process dlt/duckdb; dbt resolved at Path(sys.executable).parent / "dbt"), so this is the low-churn fit.

Getting the version right (the crux):

  • uv venv --python <X> where X satisfies >=3.12,<3.14. uv auto-downloads a python-build-standalone CPython if the system has no compatible interpreter — so a machine with only 3.14 still works with zero manual installs.
  • Write .python-version (3.12) into the project dir to pin subsequent uv commands. (Safe here — this only bit CI when placed at the package repo root.)
  • New tycoon doctor check: verify the active interpreter is in [3.12, 3.14); on failure, actionable message + tycoon doctor --fix / tycoon setup that (re)builds .venv correctly.

Bootstrap (chicken-and-egg): a tiny entry like uvx database-tycoon init (or a one-line installer) creates .venv with the right Python and installs everything into it; thereafter the user just uses that .venv.

Scope (proposed)

  • tycoon setup (and/or tycoon init integration): create/validate project .venv via uv (uv venv --python, auto-download), install tycoon + data deps.
  • Write .python-version into the project dir.
  • tycoon doctor interpreter check (range [3.12,3.14)) + --fix. Highest-leverage piece — closes the blind spot that hid requires-python has no upper bound → Python 3.14 gets selected, dbt breaks #55.
  • Locate uv via shutil.which("uv"); offer to bootstrap via the standalone installer if absent (with consent). Confirm whether the uv wheel's binary-location API (uv.find_uv_bin()) is usable at impl time.
  • Docs: collapse the current 3-way install menu (pip / uv tool / uv add) into one recommended onboarding path.
  • Tests: env-creation flow (mock uv), doctor version check (in-range / too-new / too-old).
  • Windows path handling.

Out of scope / future

  • Option B — tycoon installed once as a global uv tool, with the project .venv a separate dbt/dlt env tycoon shells into. More flexible, but needs the in-process dlt/duckdb calls refactored to subprocess + introduces two-environment confusion. Revisit later.
  • Standalone compiled binary (dbt-Fusion-style). Not now.

References

Target: v0.1.9.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions