Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[internal] Use f_globals instead of inspect.getmodule in collect_rules #16357

Merged
merged 1 commit into from
Aug 2, 2022

Conversation

chrisjrn
Copy link
Contributor

While working on #7369, I discovered that inspect.getmodule requires relevant modules to exist on the filesystem. PyOxidizer's importer imports from memory, so finding rules by inspect.getmodule will not work.

This change uses the f_globals attribute on the callling frame to get the global objects of the frame that invokes collect_rules. I believe this is functionally equivalent.

[ci skip-rust]

(cherry picked from commit 4c6c064)

[ci skip-build-wheels]
@chrisjrn chrisjrn requested review from stuhood and benjyw July 29, 2022 19:33
@chrisjrn chrisjrn added the category:bugfix Bug fixes for released features label Jul 29, 2022
@chrisjrn chrisjrn changed the title Use f_globals instead of inspect.getmodule in collect_rules [internal] Use f_globals instead of inspect.getmodule in collect_rules Jul 29, 2022
@chrisjrn
Copy link
Contributor Author

(Given that this addresses collect_rules, I suspect we'll run into at least one unit test failure here if the change is not functionally equivalent in most cases)

Copy link
Contributor

@Eric-Arellano Eric-Arellano left a comment

Choose a reason for hiding this comment

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

Thanks!

@stuhood stuhood merged commit 5c78057 into pantsbuild:main Aug 2, 2022
cczona pushed a commit to cczona/pants that referenced this pull request Sep 1, 2022
…_rules` (pantsbuild#16357)

While working on pantsbuild#7369, I discovered that `inspect.getmodule` requires relevant modules to exist on the filesystem. PyOxidizer's importer imports from memory, so finding rules by `inspect.getmodule` will not work.

This change uses the `f_globals` attribute on the callling frame to get the global objects of the frame that invokes `collect_rules`. I believe this is functionally equivalent.

[ci skip-rust]
[ci skip-build-wheels]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:bugfix Bug fixes for released features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants