#!/bin/sh
# py-compile - Compile a Python program
-scriptversion=2022-02-06.04; # UTC
+scriptversion=2022-02-06.05; # UTC
# Copyright (C) 2000-2022 Free Software Foundation, Inc.
shift
done
-files=$*
-if test -z "$files"; then
+if test $# -eq 0; then
usage_error "no files given"
fi
$PYTHON -c "
import sys, os, py_compile, $import_lib
-files = '''$files'''
-
sys.stdout.write('Byte-compiling python modules...\n')
-for file in files.split():
+for file in sys.argv[1:]:
$pathtrans
$filetrans
if not os.path.exists(filepath) or not (len(filepath) >= 3
py_compile.compile(filepath, $import_call(filepath), path)
else:
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 ...
$PYTHON -O -c "
if hasattr(sys, 'pypy_translation_info'):
sys.exit(0)
-files = '''$files'''
sys.stdout.write('Byte-compiling python modules (optimized versions) ...\n')
-for file in files.split():
+for file in sys.argv[1:]:
$pathtrans
$filetrans
if not os.path.exists(filepath) or not (len(filepath) >= 3
py_compile.compile(filepath, $import_call(filepath$import_arg2), path)
else:
py_compile.compile(filepath, filepath + 'o', path)
-sys.stdout.write('\n')" 2>/dev/null || exit $?
+sys.stdout.write('\n')" "$@" 2>/dev/null || exit $?
# Local Variables:
# mode: shell-script
--- /dev/null
+#! /bin/sh
+# Copyright (C) 2022 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
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# 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, see <https://www.gnu.org/licenses/>.
+
+# Verify 'py-compile' script can handle inputs with spaces, etc...
+
+required=python
+. test-init.sh
+
+cp "$am_scriptdir/py-compile" . \
+ || fatal_ "failed to fetch auxiliary script py-compile"
+
+# Create files that require proper quoting.
+mkdir "dir with spaces"
+touch "nospace.py" "has space.py" "*.py" "dir with spaces/|.py"
+
+./py-compile "nospace.py" "has space.py" "*.py" "dir with spaces/|.py"
+
+py_installed "nospace.pyc"
+py_installed "has space.pyc"
+py_installed "*.pyc"
+py_installed "dir with spaces/|.pyc"
+
+: