From c04c4e8856e3c933239959ce18e16599fcc04a8b Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 29 Mar 2023 18:07:10 -0700 Subject: Port py-compile to Python 2.6- * lib/py-compile: Port to Python 2.6 and earlier, which lack importlib. --- lib/py-compile | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/py-compile b/lib/py-compile index e1496a08c..d11962e96 100755 --- a/lib/py-compile +++ b/lib/py-compile @@ -1,7 +1,7 @@ #!/bin/sh # py-compile - Compile a Python program -scriptversion=2022-09-26.22; # UTC +scriptversion=2023-03-30.00; # UTC # Copyright (C) 2000-2023 Free Software Foundation, Inc. @@ -139,7 +139,12 @@ python_minor=`$PYTHON -c 'import sys; print(sys.version_info[1])'` # First byte compile (no optimization) all the modules. # This works for all currently known Python versions. $PYTHON -c " -import sys, os, py_compile, importlib +import sys, os, py_compile + +try: + import importlib +except ImportError: + importlib = None # importlib.util.cache_from_source was added in 3.4 if ( @@ -166,7 +171,12 @@ sys.stdout.write('\n')" "$@" || exit $? # Then byte compile w/optimization all the modules. $PYTHON -O -c " -import sys, os, py_compile, importlib +import sys, os, py_compile + +try: + import importlib +except ImportError: + importlib = None # importlib.util.cache_from_source was added in 3.4 if ( -- cgit v1.2.1