Skip to content

feat: revamp mk_all internals - #45108

Open
thorimur wants to merge 21 commits into
leanprover-community:masterfrom
thorimur:mk-all-path
Open

thorimur wants to merge 21 commits into
leanprover-community:masterfrom
thorimur:mk-all-path

Conversation

@thorimur

@thorimur thorimur commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

This PR revamps mk_all to

  1. correctly find the source directory and paths from the (already available) lean_libs and rely on more robust Lake API more broadly
  2. use a Config internally that accounts for the mathlib-specific exceptions, so that in the future downstream projects could read this from json instead
  3. checks that we are not overwriting a file that includes more than just imports, and demands --clobber to do so
  4. (misc.) allow multiple libraries/roots to be specified with --lib Foo,Bar,Baz

This also generally refactors the code somewhat to make it more principled and (hopefully) maintainable.

We also change the behavior of API in Mathlib.Util.GetAllModules as appropriate in order to rely on more robust paths.


@github-actions github-actions Bot added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Oct 21, 2026
@github-actions github-actions Bot removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Oct 21, 2026
@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

PR summary 68ac51c9b7

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff (regex)

+ Config
+ Config.mkAllLibs
+ Config.mkAllRoots
+ Root
+ dir
+ fileName
+ findRoot
+ getWorkspace
+ handleRoot
+ lt
+ mathlibConfig
+ mk
+ mkOnlyRoots
+ needsModule
+ ofLeanLib
- getLeanLibs

You can run this locally as follows
## from your `mathlib4` directory:
git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci

## summary with just the declaration names:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh <optional_commit>

## more verbose report:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh long <optional_commit>

The doc-module for scripts/pr_summary/declarations_diff.sh in the mathlib-ci repository contains some details about this script.

Declarations diff (Lean)

✅ Lean-aware diff — post-build, computed from the Lean environment (commit 68ac51c).

  • +0 new declarations
  • −0 removed declarations

No declaration differences.


No changes to strong technical debt.
No changes to weak technical debt.

Current commit 68ac51c9b7
Reference commit 4dc43842a1

This script lives in the mathlib-ci repository. To run it locally, from your mathlib4 directory:

git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci
../mathlib-ci/scripts/reporting/technical-debt-metrics.py pr_summary
  • The relative value is the weighted sum of the differences with weight given by the inverse of the current value of the statistic.
  • The absolute value is the relative value divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).

@mathlib-dependent-issues mathlib-dependent-issues Bot added the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label Oct 21, 2026
@grunweg grunweg added the t-meta Tactics, attributes or user commands label Oct 21, 2026

@grunweg grunweg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two small comments. The change to Mathlib/Util/GetAllModules.lean LGTM already.

Comment thread scripts/mk_all.lean Outdated
/-- Which libraries of the current package should always be excluded from `mk_all`. -/
excludedLibs : Array Name := #[]
/-- Modules (like `Mathlib.Tactic`) which are not roots of any `lean_lib`, but should be treated
like one. Assumes that the folder they draw their imports from is located at the same path but

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is not yet clear to me.

@thorimur thorimur Oct 21, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specifically the folder path bit? If so, is something like

Assumes that (as with lean_lib roots) the folder from which the given module should import is adjacent to the module, e.g. mathlib4/Mathlib/Tactic.lean imports the modules in mathlib4/Mathlib/Tactic/.

clearer? Or, is the issue the whole thing? (Tentatively changed.)

Comment thread scripts/mk_all.lean Resolved
@mathlib-dependent-issues mathlib-dependent-issues Bot removed the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label Oct 21, 2026
@mathlib-dependent-issues

Copy link
Copy Markdown

This PR/issue depends on:

@thorimur
thorimur marked this pull request as ready for review October 23, 2026 21:21

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

t-meta Tactics, attributes or user commands

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants