Build docs and run integration tests against this checkout - #94
Merged
Conversation
shenxianpeng
force-pushed
the
claude/mkdocs-issue-4167-15dhse
branch
from
August 12, 2026 16:49
17f9ea8 to
307f1e2
Compare
Contributor
Merging this PR will improve performance by 14.56%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ⚡ | test_get_yaml_loader |
394.6 µs | 344.5 µs | +14.56% |
Tip
Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.
Comparing claude/mkdocs-issue-4167-15dhse (412c9cd) with main (9cf3048)
The docs and integration hatch environments derive their dependencies from mkdocs.yml, and every documentation plugin requires the upstream 'mkdocs' distribution by name. That distribution ships a package of the same name as this project, and it is installed after it, so its files win in site-packages for anything that goes through the console script. Two things were silently running the wrong code as a result: * 'hatch run docs:build' / 'docs:deploy' built the published site with the upstream release rather than this project - visible once the release-notes page started substituting the running version, which rendered 1.6.1 * 'hatch run integration:test' shells out to 'mkdocs build' from the fixture directories, so the integration suite has been exercising the upstream release too, while reporting green Set PYTHONPATH to the project root for both environments. Hatch applies env-vars around dependency syncing and command execution alike, and the project root precedes site-packages on sys.path, so the console script and every subprocess resolve to this checkout - while the upstream distribution stays installed, keeping the plugins' requirements satisfied and the environments in sync. Also make the integration runner assert up front that the 'mkdocs' command it is about to invoke is the same code the tests were loaded from, so this can never silently regress again.
shenxianpeng
force-pushed
the
claude/mkdocs-issue-4167-15dhse
branch
from
August 12, 2026 17:32
307f1e2 to
412c9cd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The release-notes page rendered
mkdocs, version 1.6.1after #92's version-substitution hook went live. That value was correct — and that was the problem: the published docs site was being built by the upstream release, not by this project. Investigating turned up a second, worse instance of the same fault.Root cause
The
docsandintegrationenvironments derive their dependencies frommkdocs.yml, and every documentation plugin requires the upstreammkdocsdistribution by name (mkdocs-autorefs,mkdocstrings,mkdocs-literate-nav,mkdocs-redirectsall declareRequires-Dist: mkdocs), so it cannot be avoided by editing our own dependency list. That distribution ships a package of the same name as this project and is installed after it, so its files win insite-packagesfor anything resolved through the console script.Two things were silently running the wrong code:
hatch run docs:build/docs:deploy— the published site was built by the upstream release.hatch run integration:test— the runner shells out tomkdocs buildfrom the fixture directories (mkdocs/tests/integration.py), so the integration suite has been exercising the upstream release while reporting green.Fix
(and the same for
integration). Hatch appliesenv-varsaround dependency syncing and command execution alike, andPYTHONPATHprecedessite-packagesonsys.path, so the console script and every subprocess it spawns resolve to this checkout. The upstream distribution stays installed, so the plugins' requirements remain satisfied and Hatch's dependency check stays in sync — nothing is fought, reinstalled, or removed.This replaces the earlier revision of this PR, which prefixed every docs script with a
pip install --force-reinstall. That approach worked but was imperative, ran on every invocation, and left the environment holding a copy of the sources (sodocs:servewould not reflect edits). Alternatives ruled out while investigating: Hatch'spre-/post-install-commandsrun before dependency syncing and only at environment creation, so they cannot win this race; Hatch 1.18'ssourcesredirects dependencies by distribution name, which cannot matchmkdocs→mkdocs-ng; and neither the collector nor Hatch offers any way to exclude a transitive requirement.Regression guard
mkdocs/tests/integration.pynow asserts up front that themkdocscommand it is about to invoke is the same code the tests were loaded from, so a silent recurrence becomes a loud failure:Verification
From a pruned
docsenvironment, rebuilt exactly as CI does:site-packagescontains upstreammkdocs 1.6.1(real files) alongsidemkdocs_ng-1.8.0.dist-info— the collision is still there, as expectedhatch run +py=3.11 +type=default integration:testpasses with the guard activePYTHONPATHstripped makes the guard fire with the message aboveNote for later
The same name collision affects end users who install
mkdocs-ngalongside any plugin that requiresmkdocs— the winner depends on install order. That needs a packaging-level answer and deserves its own issue; this PR fixes only our own pipelines.Checklist
docs/about/release-notes.mdupdated (if applicable) — not applicable, build infrastructure only🤖 Generated with Claude Code
https://claude.ai/code/session_018Hw7x9BxxpuKiLkzjLczp9