-
Is anyone interested in seeing Jbang support Jython? An extension for Python to use JBang already exists, but I'm proposing the inverse of the functionality provided by that project. Recently I wrote a Jython (Python) script to process a JSON file that contains amongst other data structures several persistent images of HdrHistograms. The output generated by the report.py program is an HTML report. The report.py file is executed with Java and Jython as follows:
If JBang supported Jython, the Jbang augmented report.py file would look something like this:
The report.py file can then be executed as:
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 10 replies
-
problem with using jython is that jython only supports python 2 afaik ? are you aware of the graalpy integration? See https://github.com/oracle/graalpython/blob/master/graalpython/graalpy-jbang/examples/hello.java I've always wondered if something as you suggest above would be feasible via graalpy as graalpy does support later more recent python versions. |
Beta Was this translation helpful? Give feedback.
-
Yes, Jython 2.7.4 is the latest stable release, but it contains at least some Python 3 functionality like the print() function and so forth. But it is not Python 3.x A few years ago, I did look at graalpython as a potential Jython replacement, but it still had many rough edges. It should have improved a lot by now. Worth having another look. It seems that adding Jython support would be relatively simple, and very similar to how Jshell is supported. |
Beta Was this translation helpful? Give feedback.
-
Documentation discussing support for Jython in the GraalVM - https://www.graalvm.org/jdk17/reference-manual/python/Jython/ |
Beta Was this translation helpful? Give feedback.
-
It is a bit cumbersome to use graalpy (for me), but I have found a workaround solution using jpm (https://github.com/codejive/java-jpm) which incidently can be installed via jbang. |
Beta Was this translation helpful? Give feedback.
A simpler and pure JBang solution is possible using my (by now) better understanding of the Jython source code. I had a look at the Jython Java source code, and discovered a simply way of bootstrapping Jython via a Jbang Java script:
Jython.java
Any jython script can then be run with command: