Hi Arno,
what about subscribing PyKDE? Pretty low traffic ML.
On Tuesday 26 November 2002 12:47, you wrote:
> Hi,
>
> when single-stepping through some of my python files with eric3
> I get an error dialog with the message
>
> The file
> /var/tmp/python-2.2.1-build/usr/lib/python2.2/sre.py
> could not be opened.
>
> I am using python-2.2.1-45 from SuSE 8.1. I also have the rpm
> python-nothreads-2.2.1-45 installed, not sure whether that
> maytters. The same python files run fine outside of eric3.
>
> The filename in the message looks like a leftover from a build.
The problem seems to be related to the way, how eric resolves
the path of the source (using the path provided in the *.py{c,o}
files). This clashes with the way, SuSE built their python package,
which leads to these strange messages from eric. I solved this
problem with the attached script:
pycompile -vao
will byte-compile the full python installation, thus requiring root
privilege. This choke on a few files in the test tree, which
seems to be expected, and on a few files, where it's not :-(
BTW: does somebody knows a faster way to generate pyc and pyo
files in one go? (I'm using a stupid system call to get it done)
I will try to ensure a clean python build from SuSE in their next
distrib.
> Arno
Bye,
Hans-Peter
#! /usr/bin/env python
"""
usage: %s [-arv] [dirs/files] ...
byte-compiles python files/dirs
-a compile all files of current python installation
-o optimized compile, too
-r recursive behaviour
-v verbose level (cumulative)
dirs/files: to compile
"""
# (c)reated by Hans-Peter Jansen, LISA GmbH, Berlin
#
# Licence: GPL http://www.gnu.org/licenses/gpl.html
#
# 2002-11-27 hp initial version
#
# TODO:
# - testing
#
# vim:set et ts=4 sw=4:
import sys, os
import getopt
import glob
import py_compile
argv0 = os.path.basename(sys.argv[0])
optimize = 0
verbose = 0
def out(lvl, arg):
if lvl > verbose:
return
err(arg, sys.stdout)
def err(arg, ch = sys.stderr):
if arg:
ch.write(arg)
if arg[-1] != "\n":
ch.write("\n")
else:
ch.write("\n")
ch.flush()
def exit(ret=0, arg=None):
if arg:
out(0, "%s: %s" % (argv0, arg))
sys.exit(ret)
def usage(ret=0, arg=None):
if arg:
out(0, "%s: %s" % (argv0, arg))
out(0, __doc__ % (argv0))
sys.exit(ret)
def pycompile(path, recursive = 0, depth = 0):
if os.path.isdir(path):
for p in glob.glob(os.path.join(path, "*")):
if depth == 0 or recursive:
pycompile(p, recursive, depth + 1)
elif os.path.isfile(path):
f, e = os.path.splitext(path)
if e == '.py':
out(1, "compiling %s" % (path))
py_compile.compile(path)
if optimize:
out(1, "compiling %s (opt)" % (path))
os.system("python -O %s %s" % (sys.argv[0], path))
else:
out(1, "%s ignored" % (path))
if __name__ == '__main__':
#global verbose, optimize
try:
optlist, args = getopt.getopt(sys.argv[1:], "aorv")
except getopt.error, msg:
usage(1, msg)
all = 0
optimize = 0
recursive = 0
for opt, par in optlist:
if opt == '-a':
all = 1
elif opt == '-o':
optimize = 1
elif opt == '-r':
recursive = 1
elif opt == '-v':
verbose += 1
if all:
pyFullVers = sys.version.split()[0]
vl = pyFullVers.split(".")
pyVers = vl[0] + "." + vl[1]
pycompile(os.path.join(sys.prefix, "lib/python" + pyVers), 1)
else:
for p in args:
pycompile(p, recursive)