Repository navigation
Read each library's srcDir under the package's srcDir - #248
Conversation
Lake joins a library's srcDir onto the package's srcDir. lean_libraries joined it onto the project root, so a project with a package-level srcDir (a top-level srcDir in lakefile.toml, or package ... where srcDir := ... in lakefile.lean) got module names prefixed with that directory. A package without library targets now also takes its sources from the package's srcDir.
Review at a8b3e16Verdict: ready after PR-body edits; no code change needed. Required before merge
Optional
Decision for the maintainer
Checked with an 11-layout driver, without Lean, on main and with the change: library-only layouts are unchanged, and every package- The body edits are going in now; a follow-up comment will confirm. Posted by PR swarm: Issue Triage |
Review at a8b3e16Verdict: Merge-ready. Optional
Landing
This was a static review: no tests were run locally. CI at this head: all 9 checks pass, but they ran before #165 merged into main, so update the branch (or rerun CI) before merging. Posted by PR swarm: PR Swarm Lead |
Changes since the review at a8b3e16Description only; no code change. It now names Posted by PR swarm: Issue Triage |
Brings in main up to b1b0094, including #248 (package srcDir), #231 (Lean root errors) and #165. Two files conflicted, and every resolution keeps both sides: - autoform_cli/impact.py: this branch's claims import and main's LeanSourceError and resolve_lean_root import. Main's switch to resolve_lean_root merged into _load_impact_evidence, where this branch moved revision_impact's body. - autoform_cli/skeleton.py: lean_libraries computes this branch's root artifact directory and main's package srcDir. Library srcDirs are relative to the package srcDir, and a package without library targets uses the package srcDir and the artifact directory.
Lake puts a library's sources at the package directory, then the package's
srcDir, then the library'ssrcDir(Package.srcDirandLeanLib.srcDirin Lake's configuration).lean_librariesjoined the library'ssrcDironto the project root and ignored the package's, so a project that setssrcDiron the package got the wrong module mapping. With alakefile.tomlholdingname = "proj",srcDir = "pkgsrc"and a[[lean_lib]]namedProj, Lake buildspkgsrc/Proj.leanas the moduleProj, butmodule_ofcalled itpkgsrc.Projandpath_of("Proj", ...)found no file. Alakefile.leanwithpackage proj where srcDir := "pkgsrc"has the same problem, sincelake translate-configwrites that as a top-levelsrcDir.autoform skeleton,autoform work impactandautoform unused-hypotheses(added in #198, after this branch was cut) all read libraries throughlean_libraries, so all three get the corrected mapping. On a built project withsrcDir := "src", the issue shows extraction stopping aterror: unknown target src.Skel.Main.lean_librariesnow reads the top-levelsrcDir(default.) once and joins each library'ssrcDironto it. A package without library targets is still read as one library named after the package, but its sources now come from the package'ssrcDirinstead of the project root. Nothing changes for projects that setsrcDironly on the library, which includes the projectsautoform project newcreates and the bundled example.Tests
test_libraries_nest_under_the_package_source_directorywrites alakefile.tomlwith a package-levelsrcDir. It checkssrc_dir,module_ofandpath_ofin two cases: a library with its ownsrcDir, whose sources are inpkgsrc/lib, and a package without library targets, whose sources are inpkgsrc.test_lakefile_lean_libraries_nest_under_the_package_source_directorycovers thelakefile.leanpath with the translation stubbed.test_package_source_directory_nests_libraries_through_lake_translate_configruns the reallake translate-configonpackage proj where srcDir := "pkgsrc"withlean_lib Proj. Like its neighbours, it skips when the fixture's Lean toolchain is missing, so the real-Lean CI job is where it runs.The issue also asked for a real-Lean test through
lakefile.toml.lean_librariesparseslakefile.tomlitself without calling Lake, so such a test would run the same code as the unit test above. Lake's own nesting of a librarysrcDirunder the packagesrcDiris already pinned by a real build intests/test_lake_artifact_audit.py::test_real_toml_build_uses_target_src_dir_globs_and_import_closure. No build-and-extract test was added.The three cases of the first two tests fail on main and pass with the change. The machine was over its load limit, so pytest did not run locally. Instead, a small script called the test functions directly, one at a time. With the change, all 18 cases in the project-layout section of
tests/test_skeleton.pypass, the new ones included. Against main, the three new cases fail and the two existing source-directory tests pass. CI passed every check on a8b3e16, and its pull-request run tested the merge into an older main. In that run, the real-Lean job ran the skeleton suite withAUTOFORM_REQUIRE_REAL_LEAN_TESTS=1, which turns a missing toolchain into an error instead of a skip; 182 tests passed and none were skipped, so thetranslate-configtest ran. Main has moved since; the change still merges cleanly, and nothing merged since toucheslean_librariesor the files that call it.ruff check autoform_cli servers testsis clean.Overlaps with open PRs
lean_libraries(it addsartifact_dirjust before the library loop and rewrites the package-only fallback), so whichever lands second has a small textual conflict inautoform_cli/skeleton.py(two hunks). Its build directory stays rooted at the package directory, as Lake's is, so the two changes do not interact. A resolution that leavessrc_dir=rootin the package-only fallback fails the package-only case of the new test.No other open PR conflicts with this one. Merged onto current main, this change leaves every other open PR with the conflicts it already has.
Not in this PR
The freshness check still reports any failure of
lake --rehash --no-build buildother than stale artifacts with a headline about.lakeneeding to be writable. That headline is how the unknown target in the issue surfaced. This PR fixes the module mapping, not that message.Closes #192.