-
Notifications
You must be signed in to change notification settings - Fork 186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Start jpype from Java if only to improve the workflow #632
Comments
Yes, it is on the work flow. The general plan is to start Python form within Java like you would any other scripting engine. There are a few items that are on the work plan that were considered to be prerequisites.
I have been hoping that Project Panama would be included in the JVM which would make this task much simpler but appears still to be on the horizon far out of reach. Thus I am just going to have to bite the bullet and got at it with JNI. The current plan is to attack each of these in order until full support is complete. So it is definitely on the radar likely sometime after the next release. |
(there is some similarity to our development and that of insect wings. The intermediate stages have to be something useful or other priorities just eat up the time and you never reach the sky.) |
There are limited versions of the approach that could work: Don't bite off all of the JSR scripting engine support at once, like line by line evaluation. You can get it to work as a direct API, and wrap as a script engine later. (We did this with Kotlin as a scripting engine) Don't worry about more than one instance in a VM on day 1, if people need this, maybe they can live with one instance of Python (I can for example). Later they can get multiple instances. With threads and separation into different class instances, not sure what you could not find a way to workaround. You know your codebase way better than me, I know the JVM, but things outside and native libraries I haven't touched in forever (I used JNI the first years it existed and not since). You have a good library, keep it up! If I can contribute, I will, but this particular area is a bit outside of what would be productive for me. |
I made a good push on this one last week. I resolved about 80% of the issues for setting a up a reverse bridge and even managed to get an IPython console running from within Java. But the magnitude of typing that would be required for integrated code at least 2 months out and well past the 0.8 release. I will post a task list for this once I have finished the 0.8 release. |
This topic came up today for me, and I'm curious if you've made any further progress on it @Thrameos? It would indeed be very interesting to start a CPython interpreter from within the JVM. Do you have a rough idea of the timeline we might be talking about to see such a feature (not wanting to apply any pressure here, just curious!) |
There is a "mostly" working copy of this on the epypj fork of my repo. Unfortunately it is a "shit-ton" of typing to get every module of Python tested. Current state:
I have been putting about 2 days in each month towards this. But the size of the work is pretty large and unless my boss at work says I can perform the work during day hours (or some nice user wants to help me push it forward ) it will be another few months. If the third and fourth item are resolved it would be usable though I really need a lot of user input in terms of review and documentation. The complicating factor is which jpype is production quality, this fork is closer to alpha. Getting to the same level will take time. I debated putting epypj as a project fork which exists just for testing purposes until I get enough feedback to push it to the same quality level prior to merging it back in, but the path is very unclear. |
Hello from December 2022. I'm also very interested in this feature. Has there been any further progress? |
I'm curious what the difference is between this feature request and "JPype for Android". Specifically, shouldn't we be able to launch Java then (somehow) invoke Python code that accepts a reference to the existing JVM? |
There is certainly a difference. In JPype for android we are just making access to the existing JVM which was started by the system. The request here is for Java to launch Python which means locating Python, creating the Python kernel then transferring control. |
Hello, I'm also very interested in this feature, has more progress been made since the last comment? Thank you in advance :) |
When developing with jpype and you are working on both sides of the fence, having the Python side start the JVM each time is nice in the way that both resync at the same time to new versions of code. But, it is bad in terms of workflow because it requires all the Java code to be packaged up each build (into a JAR), and the classpath to be known (already is active on the Java side) which means extracting that from a Maven or Gradle build to avoid hard coding it.
The overall workflow of the Java code becomes tiresome in this model. Starting jpype from the Java side and using the existing JVM fixes this and removes both the packaging and classpath issues.
Is this on the radar for anytime soon, I see it mentioned in the FAQ of course.
The text was updated successfully, but these errors were encountered: