Skip to content

docs: fix code snippets that fail when run#46

Merged
henryiii merged 1 commit into
mainfrom
fix/broken-snippets
Jul 13, 2026
Merged

docs: fix code snippets that fail when run#46
henryiii merged 1 commit into
mainfrom
fix/broken-snippets

Conversation

@henryiii

Copy link
Copy Markdown
Contributor

🤖 AI text below 🤖

Fixes several book and slide code snippets that error or misbehave when actually run. Found by a multi-agent review pass over the workshop content.

  • Stable ABI (content/scikit-build/02_stable_abi.md, slides/4_02_stable_abi.md): use the CMake list form set(USE_SABI USE_SABI ${...}) so python_add_library actually receives the USE_SABI keyword.
  • rescale metadata exercise (content/basic-packaging/03_package.md, slides/1_03_package.md): uv pip show -v doesn't emit Summary:/Entry-points: (-v is uv's log level); switch to real pip via uv run --with pip pip show -v rescale.
  • Template metadata plugin (content/scikit-build/03_dynamic_metadata.md, slides/4_03_dynamic_metadata.md): str.format needs {project[version]} without quotes, else KeyError.
  • Overrides (content/scikit-build/05_overrides.md): the override conditional is cmake-wheel, not wheel.cmake.
  • SDist checker (content/compiled/01_compiled.md): the tool is uvx check-sdist, not check-dist.
  • approx (slides/1_04_sp_guide.md): widen the literal to approx(0.3333333333333) so 1/3 passes the default tolerance (matches the chapter).
  • Single-file script (content/basic-packaging/01_setup.md): run simple.py to match the filename that was created.
  • Lazy imports slide (slides/6_02_lazy_imports.md): restore the parser.add_argument("--foo", ...) line so args.foo works.
  • Fedora spec (content/other-tools/04_distros.md, slides/5_04_distros.md): %pyproject_buildrequires -x test so pytest is installed before %check.
  • Editable-install pitfall (content/scikit-build/04_editable_installs.md, slides/4_04_editable_installs.md): Path(__file__).parent / "my_lib.so" (raising FileNotFoundError) actually demonstrates the pitfall; the old form raised NotADirectoryError in any install.

Corrects several book and slide examples that error or misbehave when
actually executed:

- stable ABI: use CMake list form so python_add_library sees USE_SABI
- rescale metadata exercise: use real pip via uv run --with pip
- template plugin: str.format needs {project[version]} without quotes
- overrides: rename conditional wheel.cmake to cmake-wheel
- sdist checker: uvx check-sdist, not check-dist
- approx: widen literal so 1/3 comparison passes
- setup single-file: run simple.py to match the created filename
- lazy imports slide: restore parser.add_argument for args.foo
- Fedora spec: %pyproject_buildrequires -x test so pytest is available
- editable install pitfall: Path(__file__).parent, FileNotFoundError

Assisted-by: ClaudeCode:claude-opus-4-8
@henryiii henryiii merged commit 8c94da3 into main Jul 13, 2026
3 checks passed
@henryiii henryiii deleted the fix/broken-snippets branch July 13, 2026 04:50
henryiii added a commit that referenced this pull request Jul 13, 2026
The example spec was a hollow stub with only a preamble and an empty
%files section, while the chapter and slides walk through a full spec.
Flesh it out to match the walked-through spec, including the
%pyproject_buildrequires -x test fix from PR #46 so pytest is present
in the buildroot for %check.

Assisted-by: ClaudeCode:claude-opus-4-8
henryiii added a commit that referenced this pull request Jul 13, 2026
Now that #46 is merged, the chapter can include the example spec
directly instead of carrying an inline copy, so the two cannot drift
again. The Marp deck keeps its inline copy (no include mechanism).

Assisted-by: ClaudeCode:claude-opus-4-8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant