Skip to content

Commit

Permalink
Fix galsim executable when installed by scons to actually work
Browse files Browse the repository at this point in the history
  • Loading branch information
rmjarvis committed Dec 13, 2018
1 parent 0903bb0 commit eb54d1d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions bin/galsim.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"""

# Equivalent to python -m galsim ...
import runpy
import galsim.main

if __name__ == '__main__':
runpy.run_module('galsim')
galsim.main.main()
7 changes: 4 additions & 3 deletions galsim/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
from .main import main

if __name__ == '__main__':
# MJ: I didn't think the if __name__ == '__main__' thing was required inside of __main__.py,
# but without it, Python 3 runs main() twice. I don't really understand why this is, so
# if someone has a better way to structure this code, I'm open to suggestions.
# The galsim executable will import this and then run main().
# So in that case, we don't want to also run main() here, since then it would run twice.
# However, `python -m galsim config.yaml` will run this as a program, so then we do want
# to call main. Hence this `__name__ == '__main__'` block.
main()
2 changes: 1 addition & 1 deletion galsim/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def parse_args():
import argparse

# Build the parser and add arguments
parser = argparse.ArgumentParser(description=description, add_help=True, epilog=epilog)
parser = argparse.ArgumentParser(prog='galsim', description=description, add_help=True, epilog=epilog)
parser.add_argument('config_file', type=str, nargs='?', help='the configuration file')
parser.add_argument(
'variables', type=str, nargs='*',
Expand Down

0 comments on commit eb54d1d

Please sign in to comment.