From 4a31acd3e839e184ac73c94392db23bb27f1234e Mon Sep 17 00:00:00 2001 From: Weiqun Zhang Date: Thu, 23 Jun 2022 09:44:19 -0700 Subject: [PATCH] Explicitly invoke python3 According to PEP 394, a python distributor may choose to not provide the python command. In fact, that's what recent versions of macOS do. --- Tools/Backtrace/parse_bt.py | 2 +- Tools/C_scripts/describe_sources.py | 6 +----- Tools/C_scripts/gatherbuildtime.py | 6 +----- Tools/CompileTesting/compiletesting.py | 4 +--- Tools/F_scripts/dep.py | 13 +------------ Tools/F_scripts/fcheck.py | 8 +------- Tools/F_scripts/find_files_vpath.py | 4 +--- Tools/F_scripts/findparams.py | 4 +--- Tools/F_scripts/makebuildinfo.py | 2 +- Tools/F_scripts/write_probin.py | 4 +--- Tools/GNUMake/Make.defs | 5 ----- Tools/Postprocessing/python/column_depth.py | 2 +- Tools/Postprocessing/python/conv_slopes.py | 2 +- Tools/Postprocessing/python/dumpparthistory.py | 7 +------ Tools/Postprocessing/python/test_helmeos.py | 2 +- Tools/Postprocessing/python/test_parseparticles.py | 3 +-- Tools/Py_util/plotsinglevar.py | 4 +--- Tools/Release/ppCleanup.py | 2 +- Tools/Release/ppCleanupDir.py | 2 +- Tools/Release/release.py | 2 +- Tools/libamrex/configure.py | 8 +------- Tools/libamrex/mkconfig.py | 8 +------- Tools/libamrex/mkpkgconfig.py | 8 +------- Tools/libamrex/mkversionheader.py | 8 +------- Tools/typechecker/typechecker.py | 4 +--- 25 files changed, 24 insertions(+), 96 deletions(-) diff --git a/Tools/Backtrace/parse_bt.py b/Tools/Backtrace/parse_bt.py index ce4a6684911..dd0234f9120 100755 --- a/Tools/Backtrace/parse_bt.py +++ b/Tools/Backtrace/parse_bt.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import sys import re diff --git a/Tools/C_scripts/describe_sources.py b/Tools/C_scripts/describe_sources.py index c49d16694a9..97cfe5e1e1c 100755 --- a/Tools/C_scripts/describe_sources.py +++ b/Tools/C_scripts/describe_sources.py @@ -1,10 +1,6 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import sys - -if sys.version_info < (2, 7): - sys.exit("ERROR: need python 2.7 or later for dep.py") - import argparse import os import subprocess diff --git a/Tools/C_scripts/gatherbuildtime.py b/Tools/C_scripts/gatherbuildtime.py index 082ec766c28..b0b1740847f 100755 --- a/Tools/C_scripts/gatherbuildtime.py +++ b/Tools/C_scripts/gatherbuildtime.py @@ -1,11 +1,7 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 -from __future__ import print_function import sys, os, glob, operator, time -if sys.version_info < (2, 7): - sys.exit("ERROR: need python 2.7 or later for dep.py") - if __name__ == "__main__": dt = float(sys.argv[3])-float(sys.argv[2]) hours, rem = divmod(dt, 3600) diff --git a/Tools/CompileTesting/compiletesting.py b/Tools/CompileTesting/compiletesting.py index 129e83ca960..9cb5f59bac5 100755 --- a/Tools/CompileTesting/compiletesting.py +++ b/Tools/CompileTesting/compiletesting.py @@ -1,6 +1,5 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 -from __future__ import print_function import sys import os import shlex @@ -148,4 +147,3 @@ def run(command, outfile=None): if __name__ == "__main__": compiletesting(sys.argv[1:]) - diff --git a/Tools/F_scripts/dep.py b/Tools/F_scripts/dep.py index 894dcdb65e6..24bd8318fb8 100755 --- a/Tools/F_scripts/dep.py +++ b/Tools/F_scripts/dep.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # automatically generate Makefile dependencies for Fortran 90 source. # @@ -20,18 +20,7 @@ # (e.g. iso_c_binding). Add any system-provided modules to the # `IGNORES` list below -from __future__ import print_function - import sys - -if sys.version_info < (2, 7): - sys.exit("ERROR: need python 2.7 or later for dep.py") - -if sys.version[0] == "2": - reload(sys) - sys.setdefaultencoding('latin-1') - - import io import re import os diff --git a/Tools/F_scripts/fcheck.py b/Tools/F_scripts/fcheck.py index 20033f85ac9..f5be4efd726 100755 --- a/Tools/F_scripts/fcheck.py +++ b/Tools/F_scripts/fcheck.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # a simple routine to parse Fortran files and make sure that things are # declared double precision, and constants are of the form 1.0_dp_t or @@ -122,9 +122,3 @@ def visit(argFiles, dirname, files): if (badFile == 1): print " " - - - - - - diff --git a/Tools/F_scripts/find_files_vpath.py b/Tools/F_scripts/find_files_vpath.py index c9dd5485930..a52d0f28f3d 100755 --- a/Tools/F_scripts/find_files_vpath.py +++ b/Tools/F_scripts/find_files_vpath.py @@ -1,12 +1,10 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """ Take a vpath and a list of files and find where in the first vpath the first occurrence of the file. """ -from __future__ import print_function - import sys import os import argparse diff --git a/Tools/F_scripts/findparams.py b/Tools/F_scripts/findparams.py index 70280b134de..79d698ade8d 100755 --- a/Tools/F_scripts/findparams.py +++ b/Tools/F_scripts/findparams.py @@ -1,6 +1,4 @@ -#!/usr/bin/env python - -from __future__ import print_function +#!/usr/bin/env python3 import sys import os diff --git a/Tools/F_scripts/makebuildinfo.py b/Tools/F_scripts/makebuildinfo.py index e5f206339b2..4d08a571145 100755 --- a/Tools/F_scripts/makebuildinfo.py +++ b/Tools/F_scripts/makebuildinfo.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # a simple script that writes the build_info.f90 file that is used # to store information for the job_info file that we store in plotfiles. diff --git a/Tools/F_scripts/write_probin.py b/Tools/F_scripts/write_probin.py index 10ec4489066..54729eb5f5e 100755 --- a/Tools/F_scripts/write_probin.py +++ b/Tools/F_scripts/write_probin.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """This routine parses plain-text parameter files that list runtime parameters for use in our codes. The general format of a parameter @@ -24,8 +24,6 @@ """ -from __future__ import print_function - import os import sys import argparse diff --git a/Tools/GNUMake/Make.defs b/Tools/GNUMake/Make.defs index db1ce350e54..90a399e98af 100644 --- a/Tools/GNUMake/Make.defs +++ b/Tools/GNUMake/Make.defs @@ -1,8 +1,3 @@ -# Check python version -my_python_version := $(word 2, $(shell python --version 2>&1)) -ifneq ($(firstword $(sort 2.7 $(my_python_version))), 2.7) - $(error Python >= 2.7 required! Your version is $(my_python_version)) -endif ifneq (,$(findstring ~,$(AMREX_HOME))) $(warning *** AMREX_HOME string constains ~ and make will not like it. So it is replaced.) diff --git a/Tools/Postprocessing/python/column_depth.py b/Tools/Postprocessing/python/column_depth.py index 3aff2ac4705..be17d6bb663 100755 --- a/Tools/Postprocessing/python/column_depth.py +++ b/Tools/Postprocessing/python/column_depth.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import sys import numpy diff --git a/Tools/Postprocessing/python/conv_slopes.py b/Tools/Postprocessing/python/conv_slopes.py index f2fe5404aae..9f1a22e3960 100755 --- a/Tools/Postprocessing/python/conv_slopes.py +++ b/Tools/Postprocessing/python/conv_slopes.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import sys import os import commands diff --git a/Tools/Postprocessing/python/dumpparthistory.py b/Tools/Postprocessing/python/dumpparthistory.py index 092f924423b..23f6d22d1a8 100755 --- a/Tools/Postprocessing/python/dumpparthistory.py +++ b/Tools/Postprocessing/python/dumpparthistory.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # a simple routine to parse particle files and dump out the particle # histories into separate files (1 file per particle) so that they can @@ -96,8 +96,3 @@ def main(files): sys.exit(2) main(sys.argv[1:]) - - - - - diff --git a/Tools/Postprocessing/python/test_helmeos.py b/Tools/Postprocessing/python/test_helmeos.py index 890a66aef77..824f369cf60 100755 --- a/Tools/Postprocessing/python/test_helmeos.py +++ b/Tools/Postprocessing/python/test_helmeos.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # a script showing how to use the helmeos module # it reads T, rho, X data from a sample data file, calculates abar and zbar diff --git a/Tools/Postprocessing/python/test_parseparticles.py b/Tools/Postprocessing/python/test_parseparticles.py index b9181af4d8a..8a85fe2faf6 100755 --- a/Tools/Postprocessing/python/test_parseparticles.py +++ b/Tools/Postprocessing/python/test_parseparticles.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # simple script showing how to make plots of particles using the parseparticles # module @@ -92,4 +92,3 @@ def main(fileList): # this is for profiling # cProfile.run("main(sys.argv[1:])","profile.tmp2") - diff --git a/Tools/Py_util/plotsinglevar.py b/Tools/Py_util/plotsinglevar.py index 616c516c805..bb1c2abacaa 100755 --- a/Tools/Py_util/plotsinglevar.py +++ b/Tools/Py_util/plotsinglevar.py @@ -1,11 +1,9 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # a simple script to plot 2-d or 3-d BoxLib data using the matplotlib # library # -from __future__ import print_function - import matplotlib matplotlib.use('agg') diff --git a/Tools/Release/ppCleanup.py b/Tools/Release/ppCleanup.py index 109444daff3..2935d0c1983 100755 --- a/Tools/Release/ppCleanup.py +++ b/Tools/Release/ppCleanup.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import os import shutil diff --git a/Tools/Release/ppCleanupDir.py b/Tools/Release/ppCleanupDir.py index befebc15f2d..2d8a598291d 100755 --- a/Tools/Release/ppCleanupDir.py +++ b/Tools/Release/ppCleanupDir.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import os import shutil diff --git a/Tools/Release/release.py b/Tools/Release/release.py index 87de82e5a30..8f2b4d9d5dc 100755 --- a/Tools/Release/release.py +++ b/Tools/Release/release.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import os import shutil diff --git a/Tools/libamrex/configure.py b/Tools/libamrex/configure.py index ac4b399a471..ebb3cd369f4 100755 --- a/Tools/libamrex/configure.py +++ b/Tools/libamrex/configure.py @@ -1,12 +1,6 @@ -#!/usr/bin/env python - -from __future__ import print_function +#!/usr/bin/env python3 import sys - -if sys.version_info < (2, 7): - sys.exit("ERROR: need python 2.7 or later for configure.py") - import argparse def configure(argv): diff --git a/Tools/libamrex/mkconfig.py b/Tools/libamrex/mkconfig.py index 30c54f285a2..21f66348891 100755 --- a/Tools/libamrex/mkconfig.py +++ b/Tools/libamrex/mkconfig.py @@ -1,12 +1,6 @@ -#!/usr/bin/env python - -from __future__ import print_function +#!/usr/bin/env python3 import sys, re - -if sys.version_info < (2, 7): - sys.exit("ERROR: need python 2.7 or later for mkconfig.py") - import argparse def doit(defines, undefines, comp, allow_diff_comp): diff --git a/Tools/libamrex/mkpkgconfig.py b/Tools/libamrex/mkpkgconfig.py index be91e8736a8..c8a626901da 100755 --- a/Tools/libamrex/mkpkgconfig.py +++ b/Tools/libamrex/mkpkgconfig.py @@ -1,12 +1,6 @@ -#!/usr/bin/env python - -from __future__ import print_function +#!/usr/bin/env python3 import sys - -if sys.version_info < (2, 7): - sys.exit("ERROR: need python 2.7 or later for mkpkgconfig.py") - import argparse def doit(prefix, version, cflags, libs, libpriv, fflags): diff --git a/Tools/libamrex/mkversionheader.py b/Tools/libamrex/mkversionheader.py index f2f6f8865f9..b1dbf0eb2ad 100755 --- a/Tools/libamrex/mkversionheader.py +++ b/Tools/libamrex/mkversionheader.py @@ -1,12 +1,6 @@ -#!/usr/bin/env python - -from __future__ import print_function +#!/usr/bin/env python3 import sys, re - -if sys.version_info < (2, 7): - sys.exit("ERROR: need python 2.7 or later for mkversionheader.py") - import argparse def doit(code, defines): diff --git a/Tools/typechecker/typechecker.py b/Tools/typechecker/typechecker.py index 2086b22d1b5..6035b7a6c15 100755 --- a/Tools/typechecker/typechecker.py +++ b/Tools/typechecker/typechecker.py @@ -1,6 +1,4 @@ -#!/usr/bin/env python - -from __future__ import print_function +#!/usr/bin/env python3 import os import sys