Skip to content

Commit 0e27934

Browse files
committed
Use fully optional Truffle resources
1 parent b5e1a5e commit 0e27934

File tree

5 files changed

+8
-35
lines changed

5 files changed

+8
-35
lines changed

graalpython/com.oracle.graal.python.resources/src/com/oracle/graal/python/resources/PythonResource.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,13 @@
4848

4949
import com.oracle.truffle.api.CompilerDirectives;
5050
import com.oracle.truffle.api.InternalResource;
51-
import com.oracle.truffle.api.InternalResource.Id;
5251

5352
/**
5453
* This code needs to be kept in sync somehow with the suite.py code. In particular, the layouts
5554
* produced by the unpacking logic in {@link #unpackFiles} should produce the same layout as the
5655
* GRAALPYTHON_GRAALVM_SUPPORT distribution in the suite.py.
5756
*/
58-
@Id("python-home")
57+
@InternalResource.Id(value = "python-home", componentId = "python", optional = true)
5958
public final class PythonResource implements InternalResource {
6059
private static final int PYTHON_MAJOR;
6160
private static final int PYTHON_MINOR;

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/PythonLanguage.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@
8686
import com.oracle.graal.python.pegparser.sst.ModTy;
8787
import com.oracle.graal.python.pegparser.sst.StmtTy;
8888
import com.oracle.graal.python.pegparser.tokenizer.SourceRange;
89-
import com.oracle.graal.python.resources.PythonResource;
9089
import com.oracle.graal.python.runtime.GilNode;
9190
import com.oracle.graal.python.runtime.PythonContext;
9291
import com.oracle.graal.python.runtime.PythonContext.PythonThreadState;
@@ -148,7 +147,6 @@
148147
interactive = true, internal = false, //
149148
contextPolicy = TruffleLanguage.ContextPolicy.SHARED, //
150149
fileTypeDetectors = PythonFileDetector.class, //
151-
internalResources = PythonResource.class, //
152150
website = "https://www.graalvm.org/python/")
153151
@ProvidedTags({
154152
StandardTags.CallTag.class,
@@ -187,17 +185,6 @@ public final class PythonLanguage extends TruffleLanguage<PythonContext> {
187185
public static final int GRAALVM_MAJOR = 23;
188186
public static final int GRAALVM_MINOR = 1;
189187

190-
public static final Class<PythonResource> PYTHON_RESOURCE_CLASS;
191-
192-
@SuppressWarnings("unchecked")
193-
private static Class<PythonResource> getPythonResourceClass() {
194-
try {
195-
return (Class<PythonResource>) Class.forName("com.oracle.graal.python.resources.PythonResource");
196-
} catch (ClassNotFoundException e) {
197-
return null;
198-
}
199-
}
200-
201188
static {
202189
switch (RELEASE_LEVEL) {
203190
case RELEASE_LEVEL_ALPHA:
@@ -214,7 +201,6 @@ private static Class<PythonResource> getPythonResourceClass() {
214201
RELEASE_LEVEL_STRING = tsLiteral("final");
215202
}
216203

217-
PYTHON_RESOURCE_CLASS = getPythonResourceClass();
218204
try (InputStream is = PythonLanguage.class.getResourceAsStream("/graalpy_versions")) {
219205
int ch;
220206
if (MAJOR != (ch = is.read() - ' ')) {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PythonContext.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1699,17 +1699,14 @@ public void initializeHomeAndPrefixPaths(Env newEnv, String languageHome) {
16991699
}
17001700

17011701
Supplier<?>[] homeCandidates = new Supplier<?>[]{
1702+
() -> home,
17021703
() -> {
1703-
return home;
1704-
},
1705-
() -> {
1706-
if (PythonLanguage.PYTHON_RESOURCE_CLASS != null && !ImageInfo.inImageCode()) {
1707-
try {
1708-
homeResourcesFile = newEnv.getInternalResource(PythonLanguage.PYTHON_RESOURCE_CLASS).getAbsoluteFile();
1709-
return homeResourcesFile;
1710-
} catch (IOException e) {
1711-
// fall through
1712-
}
1704+
try {
1705+
TruffleFile internalResource = newEnv.getInternalResource("python-home");
1706+
homeResourcesFile = internalResource == null ? null : internalResource.getAbsoluteFile();
1707+
return homeResourcesFile;
1708+
} catch (IOException e) {
1709+
// fall through
17131710
}
17141711
return null;
17151712
}

mx.graalpython/mx_graalpython.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2160,7 +2160,6 @@ def verify_ci(dest_suite, common_ci_dir="ci_common", args=None, ext=('.jsonnet',
21602160
}},
21612161
truffle_jars=[
21622162
'graalpython:GRAALPYTHON',
2163-
'graalpython:GRAALPYTHON_RESOURCES',
21642163
'graalpython:BOUNCYCASTLE-PROVIDER',
21652164
'graalpython:BOUNCYCASTLE-PKIX',
21662165
'graalpython:BOUNCYCASTLE-UTIL',

mx.graalpython/suite.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,6 @@
393393
"dependencies": [
394394
"com.oracle.graal.python.annotations",
395395
"com.oracle.graal.python.pegparser",
396-
"com.oracle.graal.python.resources",
397396
"truffle:TRUFFLE_API",
398397
"truffle:TRUFFLE_NFI",
399398
"tools:TRUFFLE_PROFILER",
@@ -908,9 +907,6 @@
908907
"platformDependent": False,
909908
"moduleInfo": {
910909
"name": "org.graalvm.py.resources",
911-
"exports": [
912-
"com.oracle.graal.python.resources to org.graalvm.py",
913-
],
914910
},
915911
# "useModulePath": True,
916912
"dependencies": [
@@ -950,9 +946,6 @@
950946
"uses": [
951947
"com.oracle.graal.python.builtins.PythonBuiltins",
952948
],
953-
"requires": [
954-
"static org.graalvm.py.resources",
955-
],
956949
},
957950
# "useModulePath": True,
958951
"dependencies": [
@@ -968,7 +961,6 @@
968961
"sulong:SULONG_API",
969962
"sulong:SULONG_NATIVE", # this is actually just a runtime dependency
970963
"truffle:TRUFFLE_ICU4J",
971-
"GRAALPYTHON_RESOURCES", # overridden below to make this an optional dependency
972964
],
973965
"requires": [
974966
"java.base",

0 commit comments

Comments
 (0)