On 02/13/2011 01:35 PM, Patrick Atamaniuk wrote:
On Sun, Feb 13, 2011 at 3:37 PM, Richard Heck<rgh...@comcast.net> wrote:
On 02/13/2011 09:24 AM, Paul A. Rubin wrote:
I swapped a few e-mails with her and eventually discovered that she has
Python
3.1 installed. I suspect that might be the culprit but can't be sure.
Has
anyone tested the various Python scripts against Python 3?
I think we have been trying to avoid this. I think I did do some stuff with
lyx2lyx, running it with whatever that flag is that warns you about Python 3
incompatibilities, but that is all I did. Plainly, we need to do this with
all of our scripts.
Richard
in my limited experience -
Writing python code running in both 2.6 and 3 is possible, for 2.5 and
3.x it can turn out pretty hard. How to:
http://wiki.python.org/moin/PortingPythonToPy3k
If we can't control the environment, python 2 is not a bad choice to
stick for a while:
http://wiki.python.org/moin/Python2orPython3
automated code conversion might help at some point:
http://docs.python.org/library/2to3.html
I committed two simple fixes for configure.py. Here is what 2to3 says
about the rest:
[rgheck@rghquad lib]$ /usr/lib64/python3.1/Tools/scripts/2to3 configure.py
RefactoringTool: Skipping implicit fixer: buffer
RefactoringTool: Skipping implicit fixer: idioms
RefactoringTool: Skipping implicit fixer: set_literal
RefactoringTool: Skipping implicit fixer: ws_comma
RefactoringTool: Refactored configure.py
--- configure.py (original)
+++ configure.py (refactored)
@@ -996,7 +996,7 @@
prereq_latex = checkForClassExtension(classname)
else:
prereq_list = optAll[1:-1].split(',')
- prereq_list = map(checkForClassExtension, prereq_list)
+ prereq_list = list(map(checkForClassExtension,
prereq_list))
prereq_latex = ','.join(prereq_list)
prereq_docbook = {'true':'', 'false':'docbook'}[bool_docbook]
prereq = {'LaTeX':prereq_latex,
'DocBook':prereq_docbook}[classtype]
@@ -1280,13 +1280,13 @@
## Parse the command line
for op in sys.argv[1:]: # default shell/for list is $*, the options
if op in [ '-help', '--help', '-h' ]:
- print '''Usage: configure [options]
+ print('''Usage: configure [options]
Options:
--help show this help lines
--keep-temps keep temporary files (for debug. purposes)
--without-latex-config do not run LaTeX to determine configuration
--with-version-suffix=suffix suffix of binary installed files
-'''
+''')
sys.exit(0)
elif op == '--without-latex-config':
lyx_check_config = False
@@ -1295,7 +1295,7 @@
elif op[0:22] == '--with-version-suffix=': # never mind if op
is not long enough
version_suffix = op[22:]
else:
- print "Unknown option", op
+ print("Unknown option", op)
sys.exit(1)
#
# check if we run from the right directory
RefactoringTool: Files that need to be modified:
RefactoringTool: configure.py
So we have two print statements that need fixing, and one call to map().
For map(), I think the change mentioned works in 2.x anyway, right? So
that's easy.
What's the minimum Python version we require these days? If 2.6, then we
can handle the print stuff by importing print_function from __future__.
If not, then we'll have to futz around a bit and perhaps do something like:
def ourprint(s):
if sys.version_info[0] == 3:
print(s)
else:
sys.write(s + '\n')
Will that work? Or do we have to put different declarations of
ourprint() in different modules and import one or the other depending
upon which version we are running? Alternatively, we could just use
sys.write and be done with it.
Richard