7 routes42 sections324 units

Unit 5.8 · about 4 h

34 / 324

Dependency locks, run manifests and quality gates

A result that needs your laptop to reproduce is a rumor. Locks plus manifests plus gates make the same code produce the same result on another machine.

  • implement

You can now

  • Lock an application with uv lock and reproduce the environment with uv sync --locked.
  • Record code, configuration, data identity, seeds and output checksums in a run manifest.
  • Wire format, lint, typecheck, test, build and clean-install gates with pre-commit and CI.

Covers

  • Dependency locks, clean environments and repeatable builds
  • Data identity, configuration, seeds, manifests and checksums
  • Type, lint, test, build and installation gates

Study, in this order

3 steps

  1. Packaging and shipping code
    The Missing Semester of Your CS Education

    Dependencies and Environments with venv and uv; Artifacts and Packaging with pyproject.toml and uv build; Releases and Versioning with pins versus ranges; Reproducibility with uv lock, lockfile contents, hermetic Nix and Bazel, Dependabot and rollback; Configuration

  2. Code Quality: gates and automation
    The Missing Semester of Your CS Education

    Formatting; Linting; Pre-commit hooks; Continuous integration with matrices and badges; Command runners

  3. Versions, environments and packaging recipes
    Stas' Python Cookbook - debugging and testing

    Versions and Dependencies: Querying installed package versions and Virtual environments; Packaging and Requirements: Modern packaging with pyproject.toml

Focus on

  • Applications pin, libraries range. uv.lock records exact versions with hashes, and CI enforces it with uv sync --locked.
  • A manifest names everything the run needs: commit sha, config, data checksum, seed, environment lock and output hash. Diff the manifest, not memories.
  • Gates run in order of cost: format, lint, typecheck, fast tests, build, clean-environment install. Pre-commit runs the cheap ones locally; CI runs all of them.
  • Hermetic builds pin the toolchain too, for bit-identical artifacts. Reach for Nix or Bazel only when lockfiles plus containers still diverge.

Reproduce closed-book

Run uv init plus uv lock on a fresh package and get a uv.lock opening with version = 1 and revision = 3 (uv 0.11.32). Add a dependency to pyproject.toml without relocking and compare uv sync --locked, which errors, with plain uv sync, which rewrites the lock. Create a venv, diff printenv before and after, and see VIRTUAL_ENV and VIRTUAL_ENV_PROMPT appear with python resolving inside the venv.

Traps

  • Committing the venv or syncing without --locked in CI. Plain uv sync quietly re-locks when pyproject.toml changed, so CI tests versions nobody committed; --locked fails on the stale lock.
  • Pinning == in a reusable library. Your pin becomes every downstream conflict, so range the library and pin the app.
  • CI that tests the working tree but never installs the built wheel. Packaging bugs ship green, so add a clean-install smoke step.

Practice

Missing Semester environment and lockfile exercises

Exercises, items 1 and 2: printenv diff across venv activation; package with pyproject.toml plus lockfile inspection

Missing Semester formatter, linter and CI exercises

Exercises, items 1 and 3: formatter plus linter with pre-commit hooks; CI on every push with an intentional breakage

Break the build on purpose once and confirm CI catches it before review.

Self-test

  1. uv.lock exists but CI runs uv sync without --locked. What breaks?

  2. Why does the lecture recommend ranges for libraries and pins for apps?

  3. A manifest lists code sha, config, data checksum, seed, lockfile hash and output hash. Identical code gives a different output: where do you look?

  4. Pre-commit passes but CI fails on lint. What usually differs?

Completion criterion

Stop when

A clean checkout runs one command to a green gate, uv sync --locked reproduces the environment per the lock hashes, and the run manifest explains any output change.

Mark passed, then open 6.1 Only mark this when you can do it without notes.

Leads to

Comes after

Resources for this unit

  • The Missing Semester of Your CS Education
    MITprimarycourse
    Complete the 2026 lectures on the shell, command-line environment, development tools, debugging and profiling, Git, packaging and shipping code, and code quality. Apply every exercise to the same stage project.
  • Stas' Python Cookbook - debugging and testing
    Stas Bekmansupportreference
    Use Part III and the packaging sections for debugger, traceback, pytest, logging, profiling and clean-environment recipes.

Also in this section

  • pytest documentation
    pytestrequiredimplementation
    Use Get Started, fixtures, parametrization, monkeypatch, caplog and temporary paths to build behavior and failure-path tests without order dependence.
  • Hypothesis documentation
    Hypothesisrequiredpractice
    Follow the Quick start and property-based testing guides, then generate operation histories and retain the minimized example for one real defect.
  • The Art of Debugging
    Stas Bekmansupportpractice
    Use the Unix, Python and compiled-code sections during a real seeded defect. Follow the evidence and tiny-reproducer workflow rather than reading the unfinished book front to back.
  • Pro Git
    Git projectsupportreference
    Use Chapters 2-3 and the sections on debugging, internals and recovery while constructing a history for bisect and recovering a deliberately displaced commit.
  • AlgoMaster Python - mocking
    AlgoMastersupportcourse
    Use the Mocking lesson for unittest.mock: Mock versus MagicMock, patch targets, autospec and the over-mocking trap. The pytest docs remain the reference for fixtures and monkeypatch.

Quick find

Search Michi

Type to search every route, section, unit, topic and resource.

Enter opens the first result Esc closes

Reference

Keyboard shortcuts

n
Continue to the first unit not passed
j / k
Next / previous unit
1 2 3
Toggle learned, practised, passed
/
Open search
?
Show this help
Esc
Close open panels