2 # py-compile - Compile a Python program
4 scriptversion=2004-01-12.23
6 # Copyright (C) 2000-2024 CEA, EDF
8 # This library is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU Lesser General Public
10 # License as published by the Free Software Foundation; either
11 # version 2.1 of the License, or (at your option) any later version.
13 # This library is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # Lesser General Public License for more details.
18 # You should have received a copy of the GNU Lesser General Public
19 # License along with this library; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
25 # This program is free software; you can redistribute it and/or modify
26 # it under the terms of the GNU General Public License as published by
27 # the Free Software Foundation; either version 2, or (at your option)
30 # This program is distributed in the hope that it will be useful,
31 # but WITHOUT ANY WARRANTY; without even the implied warranty of
32 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 # GNU General Public License for more details.
35 # You should have received a copy of the GNU General Public License
36 # along with this program; if not, write to the Free Software
37 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
40 # As a special exception to the GNU General Public License, if you
41 # distribute this file as part of a program that contains a
42 # configuration script generated by Autoconf, you may include it under
43 # the same distribution terms that you use for the rest of that program.
45 # This file is maintained in Automake, please report
46 # bugs to <bug-automake@gnu.org> or send patches to
47 # <automake-patches@gnu.org>.
49 if [ -z "$PYTHON" ]; then
58 if test -z "$basedir"; then
59 echo "$0: Missing argument to --basedir." 1>&2
66 Usage: py-compile [--help] [--version] [--basedir DIR] FILES..."
68 Byte compile some python scripts FILES. This should be performed
69 after they have been moved to the final installation location
71 Report bugs to <bug-automake@gnu.org>.
76 echo "py-compile $scriptversion"
82 echo "$0: No files given. Try \`$0 --help' for more information." 1>&2
86 # if basedir was given, then it should be prepended to filenames before
88 if [ -z "$basedir" ]; then
91 trans="path = os.path.join('$basedir', file)"
95 import sys, os, string, py_compile
98 print('Byte-compiling python modules...')
99 for file in string.split(files):
101 if not os.path.exists(path) or not (len(path) >= 3 and path[-3:] == '.py'):
105 py_compile.compile(path)
108 # this will fail for python < 1.5, but that doesn't matter ...
110 import sys, os, string, py_compile
113 print('Byte-compiling python modules (optimized versions) ...')
114 for file in string.split(files):
116 if not os.path.exists(path) or not (len(path) >= 3 and path[-3:] == '.py'):
120 py_compile.compile(path)
121 print" 2>/dev/null || :
126 # eval: (add-hook 'write-file-hooks 'time-stamp)
127 # time-stamp-start: "scriptversion="
128 # time-stamp-format: "%:y-%02m-%02d.%02H"
129 # time-stamp-end: "$"