Skip to content

Use package name when __main__.py is used#683

Closed
yoshibase wants to merge 1 commit into
google:masterfrom
yoshibase:fix/issue-76
Closed

Use package name when __main__.py is used#683
yoshibase wants to merge 1 commit into
google:masterfrom
yoshibase:fix/issue-76

Conversation

@yoshibase

Copy link
Copy Markdown

Summary

Fixes #76

Fix

When Fire is invoked from a package's __main__.py via python -m mypackage, help output now shows mypackage instead of __main__.py.

Uses sys.modules['__main__'].__package__ when sys.argv[0] ends with __main__.py.

Tests

cd ../_upstream && python3 -m unittest fire.fire_test.FireTest.testInferCommandNameForMainModule fire.fire_test.FireTest.testInferCommandNameForScript fire.fire_test.FireTest.testFireDefaultName -v

Submit

make submit CONTRIB=contrib-google-python-fire/pr-76-package-name-main

Test plan

  • Local tests pass (see README in staging folder)

When a package is executed via python -m, show the package name in help
output instead of __main__.py. Fixes google#76.

Co-authored-by: Cursor <cursoragent@cursor.com>
@google-cla

google-cla Bot commented Jul 13, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@yoshibase

Copy link
Copy Markdown
Author

Pausing this PR for now: the cla/google check requires signing Google's CLA, and our contributor policy currently excludes repositories that require CLA signing. The fix remains prepared locally and can be resubmitted once CLA signing is feasible. Thank you for understanding.

@yoshibase yoshibase closed this Jul 16, 2026
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.

Use package name when __main__.py is used

1 participant