There is a way to run Python scripts that uses packages from Java using GraalVM and its Python module graalpython. Here is example https://github.com/paulvi/graalpython-java-template
I wonder if it is possible to bundle GraalVM engine and graalpython into my Java application and produce jar or native image (e.g. using native image compiler from GraalVM project ) ?
Starting from version 23.1, all GraalVM additional languages can now be easily embedded in Java, including non-Graal JDKs (but with caveats!) by using Maven artifacts published on Mavencentral. Those artifacts embed and transparently on-demand extract the necessary files.
With regards to native-image, the languages now behave just like any other Java library that supports native-image. There are no extra options necessary for native-image, just put the relevant jars on modulepath (preferably) or classpath.
So embedding GraalPy in Java is as simple as adding this to pom.xml (or equivalent code for the build system of your choice):
To generate native-image, one can use the Maven plugin for native-image.
More GraalPy documentation.
Old answer applicable to versions < 23.1
I think you can bundle whole GraalVM distribution with your application, like some other applications do with normal JDKs (e.g., I think IntelliJ bundles JDK with it). That would be the simplest option.
You need at least the GraalPython home directory, which contains Python standard library and other files necessary for GraalPython to run any meaningful program.
Moreover, if you want to run in JVM mode, then you need to run on GraalVM, other JDKs are not supported. In theory you could perhaps hack it somehow to run GraalPython on stock JDK with JVMCI, like it is possible with JavaScript [0], but it is going to be much more complicated with GraalPython.
In theory, you can bundle GraalPython home directory into your application by providing custom filesystem implementation 1.
[0] https://www.graalvm.org/reference-manual/js/RunOnJDK/
1 https://www.graalvm.org/truffle/javadoc/org/graalvm/polyglot/io/FileSystem.html