Closed Justinfront closed 10 years ago
I think Jython is equivalent to about v2.5 of Python: https://wiki.python.org/jython/JythonFaq/GeneralInfo#Is_Jython_the_same_language_as_Python.3F
And given that Haxe targets Python 3, and python 2.* and 3.* are different and incompatible, I'm guessing this is where your errors are coming from...
On Sat, May 3, 2014 at 1:23 PM, Justinfront notifications@github.comwrote:
After installing jython via macports ( the only one available is 2.5.2 ). Building simple hello world fails. 1) First issue is that jython requires older exception style, eg: except Exception, _hx_e: rather than newer one: except Exception as _hx_e: a lot of manual changes but viable. 2) Jython and standard python on lion ( 2.7 ) do not support nonlocal l But I found removing them seems to make no difference to execution. 3) Serious problem
Traceback (most recent call last): File "TestPython.py", line 1, in import builtins as python_lib_Builtin ImportError: No module named builtins Error: Command failed with error 255
c modules are not supported fully in jython see: http://stackoverflow.com/questions/471000/jython-and-python-modules Not sure if we can adjust to not use these modules given a flag.
I am unsure if more issues exist because I was not knowledgeable in how to circumvent the third problem, but I presume it would be preferable to support older python versions and also worthwhile allowing jython, I know hxcpp has an old gcc flag or something maybe we could consider something similar. It's not an area I have any expertise in so I do not know the importance of Jython support, but it might for instance be very useful for instance there are tutorials on swing use so it could open up some interesting graphics possibilities? https://wiki.python.org/jython/SwingExamples Also via jython maybe opengl support would be easier? The concept of freely mixing haxe java and hake python has to appeal at some level!
Anyway thought I should raise the issue as it might be easier to address now rather than later, or officially decide to document no support.
— Reply to this email directly or view it on GitHubhttps://github.com/HaxeFoundation/haxe/issues/2953 .
What Jason said.
Jython has a Python 2.7 beta. http://www.jython.org/downloads.html
Did any of you actually run some haxe python through the jython complier before closing?
As I was clear to point out issues 1 and 2 were easy fixes, issue 3 maybe more problematic. For instance issue 2 was a problem for Lion standard python 2.7 and considering lots of python code is 2.5/2.7 compatible we should slowly work out if we can support older python and extend our reach.
Haxe uses a subset of Python in targetting python so it is questionable that we really cannot support jython and python 2.5/2.7 longer term if look at the real output we get from haxe and real differences, since we support multiple flash versions.
Can we add this as a feature request?
If you think that something is an easy fix then by all means fix it. Make sure it's switchable though, and also make sure it is being tested.
We have no plans to work on support for python 2.
I understand the reasoning behind closing but feel as explained in my comments that this should be added as feature request to be considered properly at a later time haxe largely does not use all python 3 features and if you look at most haxe python output code the differences between python2.7 and python3 is less significant so like flash we should strive to support common python, I think many opensource projects use python 2.5, 2.7. So now that we have python output we could look to see if it can be modified to serve pre-python3.
Simon Krajewski:
What Jason said.
Reply to this email directly or view it on GitHub: https://github.com/HaxeFoundation/haxe/issues/2953#issuecomment-42097903
I guess I should take a look when I know python and ocaml better
hey justin, i'm open for pull requests, it would be nice to support python2.7 (but it should be a compile time decision) but that would require some changes:
1) nonlocal
this is a tricky one, nonlocal allows modification of variables in the outer scope like:
x = 0
def foo ():
nonlocal x;
x += 1
foo()
print(str(x)); // should be one
to support 2.7 we need to put all locals that are modified in a nested scope in a dictionary or a list like:
x = dict('v'=0)
def foo ():
x['v'] += 1
foo()
print(str(x['v'])); // should be one
that would require to detect if a local variable is written to in a nested scope and if yes we need to replace every read and write access to that variable with a read/write to the dict.
2) string handling (not really sure about the required changes).
3) python std library differences (python.lib), we would some #if #else blocks in class definitions and also in the implementations of the haxe std lib
The point is that i don't have the time to do this, but if somebody wants to give it a try...i'm open for it ;).
I was wondering if we could use... https://wiki.python.org/moin/3to2
RefactoringTool: Line 785: could not convert: nonlocal l
I manually removed line 785 but still got errors
jython Testpython.py
Traceback (most recent call last):
File "Testpython.py", line 15, in
ipy Testpython.py
Traceback (most recent call last):
File "Testpython.py", line 6, in
python Testpython.py
File "Testpython.py", line 204 except Exception, _hx_e: ^ SyntaxError: invalid syntax Error: Command failed with error 1
after manually swapping all of them to 'as'
Traceback (most recent call last):
File "Testpython.py", line 1, in
Not sure if you have ideas about if we could take 3to2 forward or if the python community has other solutions, but stuff like jython and IronPython etc... seem a shame to rule out.
frabbit:
hey justin, i'm open for pull requests, it would be nice to support python2.7 (but it should be a compile time decision) but that would require some changes:
1) nonlocal
this is a tricky one nonlocal allows modification of variables in the outer scope like:
x = 0 def foo (): nonlocal x; x += 1 foo() print(str(x)); // should be one
to support 2.7 we need to put all locals that are modified in a nested scope in a dictionary or a list like:
x = dict('v'=0) def foo (): x['v'] += 1 foo() print(str(x['v'])); // should be one
that would require the detection of a local is written to in a nested scope and lifting every read call to a dict lookup.
2) string handling (not really sure about the required changes).
3) std library differences, we would need a lot of #if #else blocks in class definitions and also on the call side.
The point is that i don't have the time to do this, but if somebody wants to give it a try...i'm open for it ;).
Reply to this email directly or view it on GitHub: https://github.com/HaxeFoundation/haxe/issues/2953#issuecomment-42109612
After installing jython via macports ( the only one available is 2.5.2 ). Building simple hello world fails. 1) First issue is that jython requires older exception style, eg: except Exception, _hx_e: rather than newer one: except Exception as _hx_e: a lot of manual changes but viable. 2) Jython and standard python on lion ( 2.7 ) do not support nonlocal l But I found removing them seems to make no difference to execution. 3) Serious problem
Traceback (most recent call last): File "TestPython.py", line 1, in
import builtins as python_lib_Builtin
ImportError: No module named builtins
Error: Command failed with error 255
c modules are not supported fully in jython see: http://stackoverflow.com/questions/471000/jython-and-python-modules Not sure if we can adjust to not use these modules given a flag.
I am unsure if more issues exist because I was not knowledgeable in how to circumvent the third problem, but I presume it would be preferable to support older python versions and also worthwhile allowing jython, I know hxcpp has an old gcc flag or something maybe we could consider something similar. It's not an area I have any expertise in so I do not know the importance of Jython support, but it might for instance be very useful for instance there are tutorials on swing use so it could open up some interesting graphics possibilities? https://wiki.python.org/jython/SwingExamples Also via jython maybe opengl support would be easier? The concept of freely mixing haxe java and hake python has to appeal at some level!
Anyway thought I should raise the issue as it might be easier to address now rather than later, or officially decide to document no support.