Commit e71c046e authored by Martin Pitt's avatar Martin Pitt
Browse files

m4: Update py-compile to current upstream version

Update py-compile to current versions from automake 1.11.6.
parent 8406b39f
#!/bin/sh
# py-compile - Compile a Python program
scriptversion=2005-05-14.22
scriptversion=2011-06-08.12; # UTC
# Copyright (C) 2000, 2001, 2003, 2004, 2005 Free Software Foundation, Inc.
# Copyright (C) 2000, 2001, 2003, 2004, 2005, 2008, 2009, 2011 Free
# Software Foundation, Inc.
# 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
......@@ -16,9 +17,7 @@ scriptversion=2005-05-14.22
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
......@@ -33,28 +32,36 @@ if [ -z "$PYTHON" ]; then
PYTHON=python
fi
me=py-compile
usage_error ()
{
echo "$me: $*" >&2
echo "Try \`$me --help' for more information." >&2
exit 1
}
basedir=
destdir=
files=
while test $# -ne 0; do
case "$1" in
--basedir)
basedir=$2
if test -z "$basedir"; then
echo "$0: Missing argument to --basedir." 1>&2
exit 1
if test $# -lt 2; then
usage_error "option '--basedir' requires an argument"
else
basedir=$2
fi
shift
;;
--destdir)
destdir=$2
if test -z "$destdir"; then
echo "$0: Missing argument to --destdir." 1>&2
exit 1
if test $# -lt 2; then
usage_error "option '--destdir' requires an argument"
else
destdir=$2
fi
shift
;;
-h|--h*)
-h|--help)
cat <<\EOF
Usage: py-compile [--help] [--version] [--basedir DIR] [--destdir DIR] FILES..."
......@@ -70,20 +77,27 @@ Report bugs to <bug-automake@gnu.org>.
EOF
exit $?
;;
-v|--v*)
echo "py-compile $scriptversion"
-v|--version)
echo "$me $scriptversion"
exit $?
;;
--)
shift
break
;;
-*)
usage_error "unrecognized option '$1'"
;;
*)
files="$files $1"
break
;;
esac
shift
done
files=$*
if test -z "$files"; then
echo "$0: No files given. Try \`$0 --help' for more information." 1>&2
exit 1
usage_error "no files given"
fi
# if basedir was given, then it should be prepended to filenames before
......@@ -103,38 +117,38 @@ else
fi
$PYTHON -c "
import sys, os, string, py_compile
import sys, os, py_compile
files = '''$files'''
print 'Byte-compiling python modules...'
for file in string.split(files):
sys.stdout.write('Byte-compiling python modules...\n')
for file in files.split():
$pathtrans
$filetrans
if not os.path.exists(filepath) or not (len(filepath) >= 3
and filepath[-3:] == '.py'):
continue
print file,
continue
sys.stdout.write(file)
sys.stdout.flush()
py_compile.compile(filepath, filepath + 'c', path)
print" || exit $?
sys.stdout.write('\n')" || exit $?
# this will fail for python < 1.5, but that doesn't matter ...
$PYTHON -O -c "
import sys, os, string, py_compile
import sys, os, py_compile
files = '''$files'''
print 'Byte-compiling python modules (optimized versions) ...'
for file in string.split(files):
sys.stdout.write('Byte-compiling python modules (optimized versions) ...\n')
for file in files.split():
$pathtrans
$filetrans
if not os.path.exists(filepath) or not (len(filepath) >= 3
and filepath[-3:] == '.py'):
continue
print file,
continue
sys.stdout.write(file)
sys.stdout.flush()
py_compile.compile(filepath, filepath + 'o', path)
print" 2>/dev/null || :
sys.stdout.write('\n')" 2>/dev/null || :
# Local Variables:
# mode: shell-script
......@@ -142,5 +156,6 @@ print" 2>/dev/null || :
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment