upiterbarg / mpmath

Automatically exported from code.google.com/p/mpmath
Other
0 stars 0 forks source link

py2exe compile error for exec_py3.py - on python 2.7.1 #204

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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

Original issue reported on code.google.com by Vlastimil.Brom@gmail.com on 4 Feb 2011 at 10:33

GoogleCodeExporter commented 9 years ago
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?

Original comment by fredrik....@gmail.com on 5 Feb 2011 at 7:52

GoogleCodeExporter commented 9 years ago
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

Original comment by Vlastimil.Brom@gmail.com on 7 Feb 2011 at 1:21

GoogleCodeExporter commented 9 years ago
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

Original comment by vlada.pe...@gmail.com on 23 Jul 2011 at 1:43

GoogleCodeExporter commented 9 years ago
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.

Original comment by fredrik....@gmail.com on 23 Jul 2011 at 6:42

GoogleCodeExporter commented 9 years ago
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)?

Original comment by asmeurer@gmail.com on 23 Jul 2011 at 11:27

GoogleCodeExporter commented 9 years ago
lo que dice  #3 vlada.pe...@gmail.com funciona correctamente

Original comment by lemyska...@gmail.com on 5 Feb 2013 at 4:23

GoogleCodeExporter commented 9 years ago
When I try "if PY3: exec_ = eval("exec")" it gives me RuntimeError: maximum 
recursion depth exceeded

Original comment by kushanav...@gmail.com on 9 Oct 2013 at 12:47

GoogleCodeExporter commented 9 years ago
I agree with  kushanav...@gmail.com. When chnaging the file to "exec_py3.pyQQQ" 
the error becomes "RuntimeError: maximum recursion depth exceeded"
I was trying to use Pyinstaler to use it in Linux. Same error.
Please help!!

Original comment by andresmi...@gmail.com on 8 Jan 2014 at 5:05

GoogleCodeExporter commented 9 years ago
Does it work with mpmath 0.18?

Original comment by fredrik....@gmail.com on 8 Jan 2014 at 5:43

GoogleCodeExporter commented 9 years ago
"When I try "if PY3: exec_ = eval("exec")" it gives me RuntimeError: maximum 
recursion depth exceeded"

same problem here. any solution ?

Original comment by ducarazvan9 on 28 Jan 2014 at 4:30

GoogleCodeExporter commented 9 years ago
SymPy uses

if PY3:
    exec_ = getattr(builtins, "exec")
else:
    def exec_(_code_, _globs_=None, _locs_=None):
        """Execute code in a namespace."""
        if _globs_ is None:
            frame = sys._getframe(1)
            _globs_ = frame.f_globals
            if _locs_ is None:
                _locs_ = frame.f_locals
            del frame
        elif _locs_ is None:
            _locs_ = _globs_
        exec("exec _code_ in _globs_, _locs_")

which I think is taken from six.

Original comment by asmeurer@gmail.com on 30 Jan 2014 at 1:18