Skip to content

Commit

Permalink
Merge pull request #8 from graalvm/tim/fix-graalpy-starter
Browse files Browse the repository at this point in the history
Simplify GraalPy starter
  • Loading branch information
timfel authored Oct 9, 2024
2 parents 5550bed + d311b5e commit faa4d3d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 29 deletions.
1 change: 0 additions & 1 deletion graalpy/graalpy-starter/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ repositories {
dependencies {
implementation("org.graalvm.polyglot:polyglot:24.1.0")
implementation("org.graalvm.polyglot:python:24.1.0")
implementation("org.graalvm.python:python-embedding:24.1.0")

// Use JUnit Jupiter for testing.
testImplementation("org.junit.jupiter:junit-jupiter:5.11.0")
Expand Down
26 changes: 0 additions & 26 deletions graalpy/graalpy-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@
<version>${graalpy.version}</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.graalvm.python</groupId>
<artifactId>python-embedding</artifactId>
<version>${graalpy.version}</version>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
Expand All @@ -61,27 +56,6 @@
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.graalvm.python</groupId>
<artifactId>graalpy-maven-plugin</artifactId>
<version>24.1.0</version>
<executions>
<execution>
<configuration>
<packages>
<!-- Select Python packages to install via pip. -->
<package>pyfiglet==1.0.2</package>
</packages>
</configuration>
<goals>
<goal>process-graalpy-resources</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>

<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
Expand Down
12 changes: 10 additions & 2 deletions graalpy/graalpy-starter/src/main/java/com/example/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,20 @@
package com.example;

import org.graalvm.polyglot.Context;
import org.graalvm.python.embedding.utils.GraalPyResources;
import org.graalvm.polyglot.io.IOAccess;

public class App {

public static void main(String[] args) {
try (Context context = GraalPyResources.createContext()) {
try (Context context = Context.newBuilder("python")
/* Enabling some of these is needed for various standard library modules */
.allowNativeAccess(false)
.allowCreateThread(false)
.allowIO(IOAccess.newBuilder()
.allowHostFileAccess(false)
.allowHostSocketAccess(false)
.build())
.build()) {
context.eval("python", "print('Hello from GraalPy!')");
}
}
Expand Down

0 comments on commit faa4d3d

Please sign in to comment.