summaryrefslogtreecommitdiffstats
path: root/Lib/compileall.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/compileall.py')
-rw-r--r--Lib/compileall.py20
1 files changed, 13 insertions, 7 deletions
diff --git a/Lib/compileall.py b/Lib/compileall.py
index 40b148d..aa65c6b 100644
--- a/Lib/compileall.py
+++ b/Lib/compileall.py
@@ -49,7 +49,7 @@ def _walk_dir(dir, ddir=None, maxlevels=10, quiet=0):
def compile_dir(dir, maxlevels=10, ddir=None, force=False, rx=None,
quiet=0, legacy=False, optimize=-1, workers=1,
- invalidation_mode=py_compile.PycInvalidationMode.TIMESTAMP):
+ invalidation_mode=None):
"""Byte-compile all modules in the given directory tree.
Arguments (only dir is required):
@@ -100,7 +100,7 @@ def compile_dir(dir, maxlevels=10, ddir=None, force=False, rx=None,
def compile_file(fullname, ddir=None, force=False, rx=None, quiet=0,
legacy=False, optimize=-1,
- invalidation_mode=py_compile.PycInvalidationMode.TIMESTAMP):
+ invalidation_mode=None):
"""Byte-compile one file.
Arguments (only fullname is required):
@@ -186,7 +186,7 @@ def compile_file(fullname, ddir=None, force=False, rx=None, quiet=0,
def compile_path(skip_curdir=1, maxlevels=0, force=False, quiet=0,
legacy=False, optimize=-1,
- invalidation_mode=py_compile.PycInvalidationMode.TIMESTAMP):
+ invalidation_mode=None):
"""Byte-compile all module on sys.path.
Arguments (all optional):
@@ -259,9 +259,12 @@ def main():
type=int, help='Run compileall concurrently')
invalidation_modes = [mode.name.lower().replace('_', '-')
for mode in py_compile.PycInvalidationMode]
- parser.add_argument('--invalidation-mode', default='timestamp',
+ parser.add_argument('--invalidation-mode',
choices=sorted(invalidation_modes),
- help='How the pycs will be invalidated at runtime')
+ help=('set .pyc invalidation mode; defaults to '
+ '"checked-hash" if the SOURCE_DATE_EPOCH '
+ 'environment variable is set, and '
+ '"timestamp" otherwise.'))
args = parser.parse_args()
compile_dests = args.compile_dest
@@ -290,8 +293,11 @@ def main():
if args.workers is not None:
args.workers = args.workers or None
- ivl_mode = args.invalidation_mode.replace('-', '_').upper()
- invalidation_mode = py_compile.PycInvalidationMode[ivl_mode]
+ if args.invalidation_mode:
+ ivl_mode = args.invalidation_mode.replace('-', '_').upper()
+ invalidation_mode = py_compile.PycInvalidationMode[ivl_mode]
+ else:
+ invalidation_mode = None
success = True
try: