Fix pip install; eliminate deferred imports#3
Merged
Conversation
…ev checkout ManagedProject assumed _LEANPY_ROOT always pointed at the repo root with lakefile.lean present. When installed via pip, that path resolves to site-packages and lake build fails. The managed project now detects whether the Lean source tree is local (editable install or checkout) and switches to a git-based Lake require otherwise, keyed to the package version tag. LEANPY_GIT_REV overrides the rev if needed. Moved all in-function imports to toplevel. The one circular dependency (core.py needs _register_inductive from solver.py, solver.py imports from core.py) is broken by extracting _inductive_reg.py as a small bridge module. Removed unused imports and variables flagged by ruff.
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.
Summary
_LEANPY_ROOTalways pointed at a dev checkout withlakefile.lean. When installed viauv pip install, that path resolves to site-packages andlake buildfails looking for a lakefile that does not exist. The managed lakefile now detects whether the Lean source tree is local and falls back to a git-based[[require]]keyed to the package version tag.LEANPY_GIT_REVoverrides the rev for custom builds._inductive_reg.pyto break the one genuine circular dependency (core.py / solver.py). Cleaned up unused imports and dead variables flagged by ruff.Test plan
uv run pytest tests -v(1265 passed)ruff check lean_py/cleanruff format --check lean_py/cleanmypy lean_py/ --ignore-missing-importscleanuv pip install lean_py && python -c "from lean_py.z3 import *"no longer crashes on lakefile lookup