Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[wpt] Reject python versions <3.6 (#27426)
This commit changes the entrypoint to reject any Python version that is not 3.6 or higher. It also removes the --py2 and --py3 flags. We are deliberately doing a rejection rather than a fallback to Python 3 to quickly find any remaining entrypoints using Py2.
- Loading branch information
1 parent
c134161
commit 92b1c27
Showing
4 changed files
with
14 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,11 @@ | ||
#!/usr/bin/env python | ||
#!/usr/bin/env python3 | ||
|
||
if __name__ == "__main__": | ||
import sys | ||
from tools.wpt import wpt | ||
args, extra = wpt.parse_args(sys.argv[1:]) | ||
commands = wpt.load_commands() | ||
py3only = commands[args.command]["py3only"] | ||
if (sys.version_info.major < 3 or | ||
(sys.version_info.major == 3 and sys.version_info.minor < 6)): | ||
sys.stderr.write("wpt requires Python 3.6 or higher\n") | ||
sys.exit(1) | ||
|
||
if (args.py2) and sys.version_info.major > 2: | ||
if py3only: | ||
sys.stderr.write("This command only works with Python 3\n") | ||
sys.exit(1) | ||
from subprocess import call | ||
try: | ||
sys.exit(call(['python2'] + sys.argv)) | ||
except OSError as e: | ||
if e.errno == 2: | ||
sys.stderr.write("python2 is needed to run this command\n") | ||
sys.exit(1) | ||
else: | ||
raise | ||
elif (not args.py2) and sys.version_info.major < 3: | ||
from subprocess import call | ||
try: | ||
sys.exit(call(['python3'] + sys.argv)) | ||
except OSError as e: | ||
if e.errno == 2: | ||
sys.stderr.write("python3 is needed to run this command\n") | ||
sys.exit(1) | ||
else: | ||
raise | ||
else: | ||
wpt.main() | ||
from tools.wpt import wpt | ||
wpt.main() |