-
Notifications
You must be signed in to change notification settings - Fork 141
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
Upgrade Java and Python Integration Example #225
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,16 +4,27 @@ This example demonstrates how to integrate Python in a Java application and run | |
|
||
### Prerequisites | ||
|
||
- GraalVM | ||
- [Python support](https://www.graalvm.org/latest/reference-manual/python/) | ||
- [GraalVM](https://www.graalvm.org/) | ||
- [GraalPy](https://www.graalvm.org/latest/reference-manual/python/) | ||
|
||
>Note: As of GraalVM for JDK 21, the Python runtime (GraalPy) is available as a standalone distribution. | ||
|
||
## Preparation | ||
|
||
1. Download and install the latest GraalVM JDK with the Python support using the [GraalVM JDK Downloader](https://github.com/graalvm/graalvm-jdk-downloader). | ||
1. Download and install the latest GraalVM JDK using [SDKMAN!](https://sdkman.io/). | ||
```bash | ||
sdk install java 21.0.1-graal | ||
``` | ||
2. Download and install GraalPy using `pyenv`: | ||
```bash | ||
pyenv install graalpy-23.1.0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's already |
||
``` | ||
Alternatively, download a compressed GraalPy installation file appropriate for your platform from [GitHub releases](https://github.com/oracle/graalpython/releases). | ||
|
||
3. Set the `GRAALPY_HOME` environment variable: | ||
```bash | ||
bash <(curl -sL https://get.graalvm.org/jdk) -c 'python' | ||
export GRAALPY_HOME=/.pyenv/versions/graalpy-23.1.0 | ||
``` | ||
|
||
2. Download or clone GraalVM demos repository and navigate into the `graalpy-notebook-example` directory: | ||
```bash | ||
git clone https://github.com/graalvm/graalvm-demos | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm afraid this file should be removed |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm afraid this entire pom.xml needs to be rewritten to use the graalpy-maven-plugin for 24.0, is it worth updating now? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we going to publish our graalpy-maven-plugin? That's great news if so! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, it goes out with the next release There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So @olyagpl we wait and refactor the Maven plugin for GraalPy (when it comes out)? Leave GitHub workflow running with JDK 17? |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,14 +7,30 @@ | |
<packaging>jar</packaging> | ||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
<maven.compiler.source>21</maven.compiler.source> | ||
<maven.compiler.target>21</maven.compiler.target> | ||
</properties> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.graalvm.sdk</groupId> | ||
<artifactId>graal-sdk</artifactId> | ||
<version>22.1.0</version> | ||
<artifactId>collections</artifactId> | ||
<version>23.1.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.graalvm.polyglot</groupId> | ||
<artifactId>polyglot</artifactId> | ||
<version>23.1.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.graalvm.sdk</groupId> | ||
<artifactId>word</artifactId> | ||
<version>23.1.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.graalvm.polyglot</groupId> | ||
<artifactId>python</artifactId> | ||
<version>23.1.0</version> | ||
<type>pom</type> | ||
</dependency> | ||
</dependencies> | ||
<profiles> | ||
|
@@ -25,7 +41,7 @@ | |
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>exec-maven-plugin</artifactId> | ||
<version>1.6.0</version> | ||
<version>3.1.1</version> | ||
<executions> | ||
<execution> | ||
<!-- | ||
|
@@ -39,7 +55,7 @@ | |
<goal>exec</goal> | ||
</goals> | ||
<configuration> | ||
<executable>${env.JAVA_HOME}/bin/graalpy</executable> | ||
<executable>${env.GRAALPY_HOME}/bin/graalpy</executable> | ||
<arguments> | ||
<argument>-m</argument> | ||
<argument>venv</argument> | ||
|
@@ -89,7 +105,7 @@ | |
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>exec-maven-plugin</artifactId> | ||
<version>3.0.0</version> | ||
<version>3.1.1</version> | ||
<executions> | ||
<execution> | ||
<id>default-cli</id> | ||
|
@@ -117,7 +133,7 @@ | |
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-enforcer-plugin</artifactId> | ||
<version>3.0.0-M3</version> | ||
<version>3.4.1</version> | ||
<executions> | ||
<execution> | ||
<id>enforce-graalvm-python</id> | ||
|
@@ -128,9 +144,8 @@ | |
<configuration> | ||
<rules> | ||
<requireFilesExist> | ||
<message>You must set JAVA_HOME to a GraalVM with Python installed.</message> | ||
<files> | ||
<file>${env.JAVA_HOME}/bin/graalpy</file> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need to change the env name? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesn’t change the |
||
<file>${env.GRAALPY_HOME}/bin/graalpy</file> | ||
</files> | ||
</requireFilesExist> | ||
</rules> | ||
|
@@ -143,10 +158,10 @@ | |
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.1</version> | ||
<version>3.8.1</version> | ||
<configuration> | ||
<source>8</source> | ||
<target>8</target> | ||
<source>21</source> | ||
<target>21</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can't install 'python' component on GraalVM for JDK 21. We should keep this demo testing on java-version: '17'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's one option. As I understand, you need to install GraalPy JVM standalone 23.1.1 and export GRAALPY_HOME to to using GitHub actions workflow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we decide to update this demo to a newer version of GraalPy, we no longer can/should use the
setup-graalvm
action, but you may be able to usesetup-python
, which supports GraalPy.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This demo is about an embedding, it should not install GraalPy in the action at all, only through the pom dependency