py-compile (nss-pam-ldapd-0.9.11) | : | py-compile (nss-pam-ldapd-0.9.12) | ||
---|---|---|---|---|
#!/bin/sh | #!/bin/sh | |||
# py-compile - Compile a Python program | # py-compile - Compile a Python program | |||
scriptversion=2018-03-07.03; # UTC | scriptversion=2021-02-27.01; # UTC | |||
# Copyright (C) 2000-2018 Free Software Foundation, Inc. | # Copyright (C) 2000-2021 Free Software Foundation, Inc. | |||
# This program is free software; you can redistribute it and/or modify | # This program is free software; you can redistribute it and/or modify | |||
# it under the terms of the GNU General Public License as published by | # it under the terms of the GNU General Public License as published by | |||
# the Free Software Foundation; either version 2, or (at your option) | # the Free Software Foundation; either version 2, or (at your option) | |||
# any later version. | # any later version. | |||
# This program is distributed in the hope that it will be useful, | # This program is distributed in the hope that it will be useful, | |||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
# GNU General Public License for more details. | # GNU General Public License for more details. | |||
skipping to change at line 30 | skipping to change at line 30 | |||
# As a special exception to the GNU General Public License, if you | # As a special exception to the GNU General Public License, if you | |||
# distribute this file as part of a program that contains a | # distribute this file as part of a program that contains a | |||
# configuration script generated by Autoconf, you may include it under | # configuration script generated by Autoconf, you may include it under | |||
# the same distribution terms that you use for the rest of that program. | # the same distribution terms that you use for the rest of that program. | |||
# This file is maintained in Automake, please report | # This file is maintained in Automake, please report | |||
# bugs to <bug-automake@gnu.org> or send patches to | # bugs to <bug-automake@gnu.org> or send patches to | |||
# <automake-patches@gnu.org>. | # <automake-patches@gnu.org>. | |||
if [ -z "$PYTHON" ]; then | if test -z "$PYTHON"; then | |||
PYTHON=python | PYTHON=python | |||
fi | fi | |||
me=py-compile | me=py-compile | |||
usage_error () | usage_error () | |||
{ | { | |||
echo "$me: $*" >&2 | echo "$me: $*" >&2 | |||
echo "Try '$me --help' for more information." >&2 | echo "Try '$me --help' for more information." >&2 | |||
exit 1 | exit 1 | |||
skipping to change at line 99 | skipping to change at line 99 | |||
;; | ;; | |||
*) | *) | |||
break | break | |||
;; | ;; | |||
esac | esac | |||
shift | shift | |||
done | done | |||
files=$* | files=$* | |||
if test -z "$files"; then | if test -z "$files"; then | |||
usage_error "no files given" | usage_error "no files given" | |||
fi | fi | |||
# if basedir was given, then it should be prepended to filenames before | # if basedir was given, then it should be prepended to filenames before | |||
# byte compilation. | # byte compilation. | |||
if [ -z "$basedir" ]; then | if test -z "$basedir"; then | |||
pathtrans="path = file" | pathtrans="path = file" | |||
else | else | |||
pathtrans="path = os.path.join('$basedir', file)" | pathtrans="path = os.path.join('$basedir', file)" | |||
fi | fi | |||
# if destdir was given, then it needs to be prepended to the filename to | # if destdir was given, then it needs to be prepended to the filename to | |||
# byte compile but not go into the compiled file. | # byte compile but not go into the compiled file. | |||
if [ -z "$destdir" ]; then | if test -z "$destdir"; then | |||
filetrans="filepath = path" | filetrans="filepath = path" | |||
else | else | |||
filetrans="filepath = os.path.normpath('$destdir' + os.sep + path)" | filetrans="filepath = os.path.normpath('$destdir' + os.sep + path)" | |||
fi | ||||
python_major=`$PYTHON -V 2>&1 | sed -e 's/.* //;s/\..*$//;1q'` | ||||
if test -z "$python_major"; then | ||||
echo "$me: could not determine $PYTHON major version, guessing 3" >&2 | ||||
python_major=3 | ||||
fi | ||||
# The old way to import libraries was deprecated. | ||||
if test "$python_major" -le 2; then | ||||
import_lib=imp | ||||
import_test="hasattr(imp, 'get_tag')" | ||||
import_call=imp.cache_from_source | ||||
import_arg2=', False' # needed in one call and not the other | ||||
else | ||||
import_lib=importlib | ||||
import_test="hasattr(sys.implementation, 'cache_tag')" | ||||
import_call=importlib.util.cache_from_source | ||||
import_arg2= | ||||
fi | fi | |||
$PYTHON -c " | $PYTHON -c " | |||
import sys, os, py_compile, imp | import sys, os, py_compile, $import_lib | |||
files = '''$files''' | files = '''$files''' | |||
sys.stdout.write('Byte-compiling python modules...\n') | sys.stdout.write('Byte-compiling python modules...\n') | |||
for file in files.split(): | for file in files.split(): | |||
$pathtrans | $pathtrans | |||
$filetrans | $filetrans | |||
if not os.path.exists(filepath) or not (len(filepath) >= 3 | if not os.path.exists(filepath) or not (len(filepath) >= 3 | |||
and filepath[-3:] == '.py'): | and filepath[-3:] == '.py'): | |||
continue | continue | |||
sys.stdout.write(file) | sys.stdout.write(file) | |||
sys.stdout.flush() | sys.stdout.flush() | |||
if hasattr(imp, 'get_tag'): | if $import_test: | |||
py_compile.compile(filepath, imp.cache_from_source(filepath), path) | py_compile.compile(filepath, $import_call(filepath), path) | |||
else: | else: | |||
py_compile.compile(filepath, filepath + 'c', path) | py_compile.compile(filepath, filepath + 'c', path) | |||
sys.stdout.write('\n')" || exit $? | sys.stdout.write('\n')" || exit $? | |||
# this will fail for python < 1.5, but that doesn't matter ... | # this will fail for python < 1.5, but that doesn't matter ... | |||
$PYTHON -O -c " | $PYTHON -O -c " | |||
import sys, os, py_compile, imp | import sys, os, py_compile, $import_lib | |||
# pypy does not use .pyo optimization | # pypy does not use .pyo optimization | |||
if hasattr(sys, 'pypy_translation_info'): | if hasattr(sys, 'pypy_translation_info'): | |||
sys.exit(0) | sys.exit(0) | |||
files = '''$files''' | files = '''$files''' | |||
sys.stdout.write('Byte-compiling python modules (optimized versions) ...\n') | sys.stdout.write('Byte-compiling python modules (optimized versions) ...\n') | |||
for file in files.split(): | for file in files.split(): | |||
$pathtrans | $pathtrans | |||
$filetrans | $filetrans | |||
if not os.path.exists(filepath) or not (len(filepath) >= 3 | if not os.path.exists(filepath) or not (len(filepath) >= 3 | |||
and filepath[-3:] == '.py'): | and filepath[-3:] == '.py'): | |||
continue | continue | |||
sys.stdout.write(file) | sys.stdout.write(file) | |||
sys.stdout.flush() | sys.stdout.flush() | |||
if hasattr(imp, 'get_tag'): | if $import_test: | |||
py_compile.compile(filepath, imp.cache_from_source(filepath, False), pat | py_compile.compile(filepath, $import_call(filepath$import_arg2), path) | |||
h) | ||||
else: | else: | |||
py_compile.compile(filepath, filepath + 'o', path) | py_compile.compile(filepath, filepath + 'o', path) | |||
sys.stdout.write('\n')" 2>/dev/null || : | sys.stdout.write('\n')" 2>/dev/null || exit $? | |||
# Local Variables: | # Local Variables: | |||
# mode: shell-script | # mode: shell-script | |||
# sh-indentation: 2 | # sh-indentation: 2 | |||
# eval: (add-hook 'before-save-hook 'time-stamp) | # eval: (add-hook 'before-save-hook 'time-stamp) | |||
# time-stamp-start: "scriptversion=" | # time-stamp-start: "scriptversion=" | |||
# time-stamp-format: "%:y-%02m-%02d.%02H" | # time-stamp-format: "%:y-%02m-%02d.%02H" | |||
# time-stamp-time-zone: "UTC0" | # time-stamp-time-zone: "UTC0" | |||
# time-stamp-end: "; # UTC" | # time-stamp-end: "; # UTC" | |||
# End: | # End: | |||
End of changes. 13 change blocks. | ||||
18 lines changed or deleted | 36 lines changed or added |