Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions graalpython/com.oracle.graal.python.annotations/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,28 @@ SOFTWARE.

<artifactId>com.oracle.graal.python.annotations</artifactId>
<packaging>jar</packaging>

<build>
<plugins>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-mx-generated-sources</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>../../mxbuild/graalpython/com.oracle.graal.python.annotations/src_gen</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
24 changes: 24 additions & 0 deletions graalpython/com.oracle.graal.python.bouncycastle/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,28 @@ SOFTWARE.
<artifactId>bcutil-jdk18on</artifactId>
</dependency>
</dependencies>

<build>
<plugins>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-mx-generated-sources</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>../../mxbuild/graalpython/com.oracle.graal.python.bouncycastle/src_gen</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
24 changes: 24 additions & 0 deletions graalpython/com.oracle.graal.python.pegparser/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,28 @@ SOFTWARE.
<artifactId>icu4j</artifactId>
</dependency>
</dependencies>

<build>
<plugins>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-mx-generated-sources</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>../../mxbuild/graalpython/com.oracle.graal.python.pegparser/src_gen</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
24 changes: 24 additions & 0 deletions graalpython/com.oracle.graal.python.processor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,28 @@ SOFTWARE.
<artifactId>com.oracle.graal.python.annotations</artifactId>
</dependency>
</dependencies>

<build>
<plugins>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-mx-generated-sources</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>../../mxbuild/graalpython/com.oracle.graal.python.processor/src_gen</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
32 changes: 32 additions & 0 deletions graalpython/com.oracle.graal.python.resources/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ SOFTWARE.
<packaging>jar</packaging>

<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>com.oracle.graal.python</artifactId>
</dependency>
<dependency>
<groupId>org.graalvm.sdk</groupId>
<artifactId>nativeimage</artifactId>
</dependency>
<dependency>
<groupId>org.graalvm.truffle</groupId>
<artifactId>truffle-api</artifactId>
Expand All @@ -66,4 +74,28 @@ SOFTWARE.
<optional>true</optional>
</dependency>
</dependencies>

<build>
<plugins>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-mx-generated-sources</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>../../mxbuild/graalpython/com.oracle.graal.python.resources/src_gen</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
com.oracle.graal.python.resources.GraalPyPlatformInfoProviderImpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/*
* Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* The Universal Permissive License (UPL), Version 1.0
*
* Subject to the condition set forth below, permission is hereby granted to any
* person obtaining a copy of this software, associated documentation and/or
* data (collectively the "Software"), free of charge and under any and all
* copyright rights in the Software, and any and all patent rights owned or
* freely licensable by each licensor hereunder covering either (i) the
* unmodified Software as contributed to or provided by such licensor, or (ii)
* the Larger Works (as defined below), to deal in both
*
* (a) the Software, and
*
* (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
* one is included with the Software each a "Larger Work" to which the Software
* is contributed by such licensors),
*
* without restriction, including without limitation the rights to copy, create
* derivative works of, display, perform, and distribute the Software and make,
* use, sell, offer for sale, import, export, have made, and have sold the
* Software and the Larger Work(s), and to sublicense the foregoing rights on
* either these or other terms.
*
* This license is subject to the following condition:
*
* The above copyright notice and either this complete permission notice or at a
* minimum a reference to the UPL must be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.oracle.graal.python.resources;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.List;

import com.oracle.graal.python.runtime.platform.GraalPyPlatformInfoProvider;
import com.oracle.truffle.api.InternalResource.CPUArchitecture;
import com.oracle.truffle.api.InternalResource.OS;

public final class GraalPyPlatformInfoProviderImpl implements GraalPyPlatformInfoProvider {
/**
* The version generated at build time is stored in an ASCII-compatible way. At build time, we
* added the ordinal value of some base character (in this case {@code '!'}) to ensure that we
* have a printable character.
*/
private static final int VERSION_BASE = '!';

private static final class VersionsInfoHolder {
private static final VersionsInfo INFO = readVersionsInfo(OS.getCurrent(), CPUArchitecture.getCurrent());
}

@Override
public PlatformInfo getPlatformInfo() {
return getVersionsInfo().platformInfo();
}

static VersionsInfo getVersionsInfo() {
return VersionsInfoHolder.INFO;
}

static VersionsInfo readVersionsInfo(OS os, CPUArchitecture cpuArchitecture) {
String resource = "/META-INF/resources/" + os + "/" + cpuArchitecture + "/graalpy_versions";
try (InputStream stream = GraalPyPlatformInfoProviderImpl.class.getResourceAsStream(resource)) {
if (stream == null) {
throw new IllegalStateException("Missing GraalPy platform metadata resource: " + resource);
}
List<String> lines = new BufferedReader(new InputStreamReader(stream, StandardCharsets.US_ASCII)).lines().toList();
if (lines.size() < 4 || lines.get(0).length() < 7) {
throw new IllegalStateException("Malformed GraalPy platform metadata resource: " + resource);
}
String versions = lines.get(0);
return new VersionsInfo(
versions.charAt(0) - VERSION_BASE,
versions.charAt(1) - VERSION_BASE,
versions.charAt(3) - VERSION_BASE,
versions.charAt(4) - VERSION_BASE,
lines.get(1).strip(),
new PlatformInfo(lines.get(2).strip(), lines.get(3).strip()));
} catch (IOException e) {
throw new IllegalStateException("Cannot read GraalPy platform metadata resource: " + resource, e);
}
}

record VersionsInfo(int pythonMajor, int pythonMinor, int graalVMajor, int graalVMinor, String pythonAbiFlags, PlatformInfo platformInfo) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.InvalidPathException;
import java.nio.file.Path;
import java.util.ArrayList;
Expand All @@ -63,40 +61,6 @@
*/
@InternalResource.Id(value = "python-home", componentId = "python", optional = true)
public final class PythonResource implements InternalResource {
private static final int PYTHON_MAJOR;
private static final int PYTHON_MINOR;
private static final int GRAALVM_MAJOR;
private static final int GRAALVM_MINOR;
private static final String PYTHON_ABIFLAGS;

/**
* The version generated at build time is stored in an ASCII-compatible way. Add build time, we
* added the ordinal value of some base character (in this case {@code '!'}) to ensure that we
* have a printable character.
*/
private static final int VERSION_BASE = '!';

static {
// See static ctor of PythonLanguage
try (InputStream is = PythonResource.class.getResourceAsStream("/graalpy_versions")) {
PYTHON_MAJOR = is.read() - VERSION_BASE;
PYTHON_MINOR = is.read() - VERSION_BASE;
is.read(); // skip python micro version
GRAALVM_MAJOR = is.read() - VERSION_BASE;
GRAALVM_MINOR = is.read() - VERSION_BASE;
is.read(); // skip GraalVM micro version
is.read(); // skip release level
int ch;
while ((ch = is.read()) != '\n' && ch != -1) {
// skip ABI version
}
String[] abiParts = ch == -1 ? new String[0] : new String(is.readAllBytes(), StandardCharsets.US_ASCII).split("\\R", 4);
PYTHON_ABIFLAGS = abiParts.length > 0 ? abiParts[0].strip() : "";
} catch (IOException e) {
throw new RuntimeException(e);
}
}

private static final Path BASE_PATH = Path.of("META-INF", "resources");
private static final String LIBGRAALPY = "libgraalpy";
private static final String LIBPYTHON = "libpython";
Expand All @@ -110,24 +74,27 @@ public final class PythonResource implements InternalResource {
private static final Path LIBPYTHON_SHA256 = Path.of(LIBPYTHON + ".sha256");
private static final Path INCLUDE_SHA256 = Path.of("include.sha256");
private static final Path NI_SHA256 = Path.of("ni.sha256");
private static final Path VERSIONS_SHA256 = Path.of("versions.sha256");
private static final Path NATIVE_SHA256 = Path.of("native.sha256");

@Override
public void unpackFiles(Env env, Path targetDirectory) throws IOException {
OS os = env.getOS();
CPUArchitecture cpuArchitecture = env.getCPUArchitecture();
Path osArch = Path.of(os.toString()).resolve(cpuArchitecture.toString());
GraalPyPlatformInfoProviderImpl.VersionsInfo versionsInfo = GraalPyPlatformInfoProviderImpl.getVersionsInfo();
ResourcesFilter filter = new ResourcesFilter();
if (os.equals(OS.WINDOWS)) {
env.unpackResourceFiles(BASE_PATH.resolve(LIBPYTHON_FILES), targetDirectory.resolve("Lib"), BASE_PATH.resolve(LIBPYTHON), filter);
env.unpackResourceFiles(BASE_PATH.resolve(LIBGRAALPY_FILES), targetDirectory.resolve("lib-graalpython"), BASE_PATH.resolve(LIBGRAALPY), filter);
env.unpackResourceFiles(BASE_PATH.resolve(INCLUDE_FILES), targetDirectory.resolve("Include"), BASE_PATH.resolve(INCLUDE), filter);
} else {
String pythonMajMin = "python" + PYTHON_MAJOR + "." + PYTHON_MINOR;
String pythonMajMin = "python" + versionsInfo.pythonMajor() + "." + versionsInfo.pythonMinor();
env.unpackResourceFiles(BASE_PATH.resolve(LIBPYTHON_FILES), targetDirectory.resolve("lib").resolve(pythonMajMin), BASE_PATH.resolve(LIBPYTHON), filter);
env.unpackResourceFiles(BASE_PATH.resolve(LIBGRAALPY_FILES), targetDirectory.resolve("lib").resolve("graalpy" + GRAALVM_MAJOR + "." + GRAALVM_MINOR), BASE_PATH.resolve(LIBGRAALPY),
env.unpackResourceFiles(BASE_PATH.resolve(LIBGRAALPY_FILES),
targetDirectory.resolve("lib").resolve("graalpy" + versionsInfo.graalVMajor() + "." + versionsInfo.graalVMinor()), BASE_PATH.resolve(LIBGRAALPY),
filter);
env.unpackResourceFiles(BASE_PATH.resolve(INCLUDE_FILES), targetDirectory.resolve("include").resolve(pythonMajMin + PYTHON_ABIFLAGS), BASE_PATH.resolve(INCLUDE), filter);
env.unpackResourceFiles(BASE_PATH.resolve(INCLUDE_FILES), targetDirectory.resolve("include").resolve(pythonMajMin + versionsInfo.pythonAbiFlags()), BASE_PATH.resolve(INCLUDE), filter);
}
// ni files are in the same place on all platforms
env.unpackResourceFiles(BASE_PATH.resolve(NI_FILES), targetDirectory, BASE_PATH, filter);
Expand Down Expand Up @@ -242,6 +209,7 @@ public String versionHash(Env env) {
CPUArchitecture cpuArchitecture = env.getCPUArchitecture();
if (!os.equals(OS.UNSUPPORTED) && !cpuArchitecture.equals(CPUArchitecture.UNSUPPORTED)) {
al = new ArrayList<>(al);
al.add(Path.of(os.toString()).resolve(cpuArchitecture.toString()).resolve(VERSIONS_SHA256));
al.add(Path.of(os.toString()).resolve(cpuArchitecture.toString()).resolve(NATIVE_SHA256));
}
for (var s : al) {
Expand Down
24 changes: 24 additions & 0 deletions graalpython/com.oracle.graal.python.shell/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,28 @@ SOFTWARE.
<artifactId>maven-downloader</artifactId>
</dependency>
</dependencies>

<build>
<plugins>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-mx-generated-sources</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>../../mxbuild/graalpython/com.oracle.graal.python.shell/src_gen</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Loading
Loading