Skip to content

Update build-script-helper.py to Python 3 #151

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

Merged
merged 1 commit into from
Jun 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions Utilities/build-script-helper.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/usr/bin/env python

from __future__ import print_function
#!/usr/bin/env python3
Copy link
Contributor

Choose a reason for hiding this comment

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

Depending on the python 3 version I'm not sure just this change is enough. It's fine for valid args but running with no args ends up with a stacktrace instead of error - I believe this is caused by the behavior of add_subparsers. It should now take required=True in Python >= 3.7.


import argparse
import os
Expand Down Expand Up @@ -93,7 +91,10 @@ def add_common_args(parser):
parser.add_argument('--sanitize-all', action='store_true', help='build using every available sanitizer in sub-directories of build path')
parser.add_argument('--verbose', '-v', action='store_true', help='enable verbose output')

subparsers = parser.add_subparsers(title='subcommands', dest='action', metavar='action')
if sys.version_info >= (3,7,0):
subparsers = parser.add_subparsers(title='subcommands', dest='action', required=True, metavar='action')
else:
subparsers = parser.add_subparsers(title='subcommands', dest='action', metavar='action')
build_parser = subparsers.add_parser('build', help='build the package')
add_common_args(build_parser)

Expand Down
2 changes: 1 addition & 1 deletion Utilities/import-llvm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

# This is a helper script for importing the things we use from LLVM.
#
Expand Down