Skip to content

Support complex package graphs#6

Merged
alvinwan merged 2 commits intomainfrom
dev/alvin/support-complex-package-graphs
Apr 4, 2026
Merged

Support complex package graphs#6
alvinwan merged 2 commits intomainfrom
dev/alvin/support-complex-package-graphs

Conversation

@alvinwan
Copy link
Copy Markdown
Owner

@alvinwan alvinwan commented Apr 4, 2026

Summary

  • resolve internal relative and dotted imports across package graphs during cross-file minification
  • switch bundle mode from source concatenation to a loader-backed single-file runtime that preserves internal import semantics
  • add execution-based coverage for relative imports, star re-exports, dotted imports, package __init__ re-exports, and importlib-based internal imports

Why

The existing multi-file path only reliably handled straightforward from module import name cases. More realistic package graphs broke in both package mode and bundle mode because import resolution and bundling were too simplistic.

Validation

  • .venv/bin/python -m pytest
  • .venv/bin/python -m build

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b148e43926

ℹ️ 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".

Comment thread pymini/pymini.py Outdated
Comment on lines +341 to +342
if self.keep_global_variables and node.id in self.public_global_names:
return self.generic_visit(node)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Rename shadowed locals even when global name is public

The new public_global_names check skips every Name whose text matches a top-level assignment, but it does not account for scope. With keep_global_variables=True (the CLI default), a function-local variable that shadows a global can be renamed at assignment time while later reads are left unrenamed, changing runtime behavior (e.g., a local x assignment followed by print(x) can start reading the global x instead). This is a semantic regression introduced by the unconditional name-based early return.

Useful? React with 👍 / 👎.

Comment thread pymini/pymini.py Outdated
if fullname not in _M:return None
return _u.spec_from_loader(fullname,_L(fullname),is_package=fullname in _P)
_s.meta_path.insert(0,_F())
for _m in {entry_modules!r}:__import__(_m)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Run bundled entrypoint as main

Bundle execution now imports each entry module with __import__, which runs module code under its module name instead of "__main__". As a result, standard guarded entry blocks (if __name__ == "__main__": ...) in bundled scripts no longer execute, so bundled output can silently do nothing where the original script previously ran. This is a behavior change in bundle mode and breaks common Python entrypoint patterns.

Useful? React with 👍 / 👎.

@alvinwan alvinwan merged commit fcf8e06 into main Apr 4, 2026
10 checks passed
@alvinwan alvinwan deleted the dev/alvin/support-complex-package-graphs branch April 5, 2026 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant