[codex] Fix package import rewrites and benchmark docs - #15
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 96227eb8f5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if base_parts and rewritten_module.startswith(".".join(base_parts) + "."): | ||
| node.module = rewritten_module[len(".".join(base_parts)) + 1:] | ||
| else: | ||
| node.module = rewritten_module |
There was a problem hiding this comment.
Avoid rewriting bare relative imports to
.pkg
This relative-import rewrite path assigns node.module to the package name when node.level > 0, which breaks statements like from . import helpers inside non-__init__ package modules. After renaming, it can unparse to from .pkg import ..., which resolves as pkg.pkg and fails at import time (ModuleNotFoundError) when --rename-modules is enabled. For bare relative imports, the module should stay unset (or be rewritten to a truly relative target), not forced to the absolute package name.
Useful? React with 👍 / 👎.
What changed
This updates package-mode import rewriting and refreshes the benchmark docs.
from . import minificationwhen module renaming is enabled--rename-modulespymini + pyminifierwheel row and short failure notes for remaining failed experiments.bench-repos/to.gitignoreWhy
The
pymini + pyminifierwheel benchmark was still failing because the minifiedpyminifier/__init__.pykeptfrom . import minificationeven after the file had been renamed. During wheel builds, importingpyminifierfromsetup.pythen failed with a circular import error from the partially initialized package.Impact
pymini + pyminifierwheel benchmark now succeedsValidation
PYTHONPATH=. .venv/bin/python -m pytest -q->58 passedpymini + pyminifierwheel benchmark flow and confirmed the wheel now builds successfullypyminifierwheel row