New issue 204 by Vlastimi...@gmail.com: py2exe compile error for
exec_py3.py - on python 2.7.1
http://code.google.com/p/mpmath/issues/detail?id=204
Hi all,
I just wanted to report one issue I encountered while trying mpmath 0.17
with py2exe, which probably arose with the added py3 support.
I am using python 2.7.1 on winXPp, py2exe-0.6.9 and mpmath 0.17 in this
case.
The relevant part of my script source only contains "import mpmath" to make
it available in the exe-d app.
Now, it seems, that py2exe somehow tries to compile also the inappropriate
exec_py3.py resulting in:
"""
error: compiling 'C:\Python27\lib\site-packages\mpmath\libmp\exec_py3.py'
failed
SyntaxError: invalid syntax (exec_py3.py, line 1)
"""
Renaming the extension of the respective file to e.g. exec_py3.pyQQQ
seems to circumvent the problem with py2exe, the exe-compilation runs ok
and the app seems to be working.
Unfortunately, I don't know enough about both libraries to know, whether
this can be handled in some more elegant way, be it in py2exe or mpmath.
regards,
Vlastimil Brom
Does py2exe not have an option to ignore a specific file?
Removing (or renaming) the file should be an ok solution, if it's not too
much trouble.
I couldn't think of a better way to support exec in both Python 2.x and
3.x, unfortunately. Anyone else have a good idea?
Thanks for the answer; if it isn't going to break anything on python 2.7, I
am quite happy with renaming the mentioned file.
I actually only use basic features of py2exe and I may be missing some
relevant parameters; the only one I know of in thic context - excludes -
doesn't seem to apply here, it probably doesn't involve compiling but only
the not-including to the executables folder.
regards,
Vlastimil Brom
Re: exec: you can try handling it with:
if PY3:
exec_ = eval("exec")
That shouldn't report any errors. Solution from six:
https://bitbucket.org/gutworth/six/src/b44b9955e9a5/six.py
Yes, that's probably the right way to do it. The "if PY3" case is actually
simple; it's the other one that's hard, but six.py seems to have a working
solution.
Can you make a note at http://code.google.com/p/sympy/issues/detail?id=2598
for any fixes you make to syntax errors in Python 2, so I can fix them in
SymPy before the release (apparently pip complains about them)?