Skip to content

Commit 5560c3c

Browse files
committed
[GR-59029] Fix coverage after sulong managed removal.
PullRequest: graalpython/3514
2 parents 95fc9bb + f78a248 commit 5560c3c

File tree

6 files changed

+36
-15
lines changed

6 files changed

+36
-15
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ language runtime. The main focus is on user-observable behavior of the engine.
1212
** Foreign lists now inherit from Python `list`, foreign dictionaries from `dict`, foreign iterators from `iterator`, foreign exceptions from `BaseException` and foreign none/null from `NoneType`.
1313
** This means all Python methods of these types are available on the corresponding foreign objects, which behave as close as possible as if they were Python objects.
1414
** See [the documentation](https://github.com/oracle/graalpython/blob/master/docs/user/Interoperability.md#interacting-with-foreign-objects-from-python-scripts) for more information.
15+
* Remove support for running with Sulong managed both in embeddings as well as through the `graalpy-managed` launcher.
1516

1617
## Version 24.1.0
1718
* GraalPy is now considered stable for pure Python workloads. While many workloads involving native extension modules work, we continue to consider them experimental. You can use the command-line option `--python.WarnExperimentalFeatures` to enable warnings for such modules at runtime. In Java embeddings the warnings are enabled by default and you can suppress them by setting the context option 'python.WarnExperimentalFeatures' to 'false'.

ci.jsonnet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "overlay": "5f2c190a2db5461ac877a32df039c3584ae08148" }
1+
{ "overlay": "9b1a2dbacd9cb2b783a4d267e283377be0bb7f8b" }

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/Python3Core.java

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import static com.oracle.graal.python.nodes.BuiltinNames.T_NT;
3333
import static com.oracle.graal.python.nodes.BuiltinNames.T_STDERR;
3434
import static com.oracle.graal.python.nodes.BuiltinNames.T_SYS;
35+
import static com.oracle.graal.python.nodes.BuiltinNames.T_ZIPIMPORT;
3536
import static com.oracle.graal.python.nodes.BuiltinNames.T__WEAKREF;
3637
import static com.oracle.graal.python.nodes.BuiltinNames.T___BUILTINS__;
3738
import static com.oracle.graal.python.nodes.BuiltinNames.T___IMPORT__;
@@ -45,6 +46,8 @@
4546
import static com.oracle.graal.python.util.PythonUtils.tsLiteral;
4647

4748
import java.io.IOException;
49+
import java.io.StringWriter;
50+
import java.io.PrintWriter;
4851
import java.math.BigInteger;
4952
import java.util.ArrayList;
5053
import java.util.Arrays;
@@ -373,6 +376,7 @@
373376
import com.oracle.graal.python.runtime.PythonContext;
374377
import com.oracle.graal.python.runtime.PythonImageBuildOptions;
375378
import com.oracle.graal.python.runtime.PythonOptions;
379+
import com.oracle.graal.python.runtime.exception.ExceptionUtils;
376380
import com.oracle.graal.python.runtime.exception.PException;
377381
import com.oracle.graal.python.runtime.interop.PythonMapScope;
378382
import com.oracle.graal.python.runtime.object.PythonObjectSlowPathFactory;
@@ -914,6 +918,7 @@ private void initializeJavaCore() {
914918
private void initializeImportlib() {
915919
PythonModule bootstrap = ImpModuleBuiltins.importFrozenModuleObject(this, T__FROZEN_IMPORTLIB, false);
916920
PythonModule bootstrapExternal;
921+
boolean useFrozenModules = bootstrap != null;
917922

918923
PyObjectCallMethodObjArgs callNode = PyObjectCallMethodObjArgs.getUncached();
919924
WriteAttributeToPythonObjectNode writeNode = WriteAttributeToPythonObjectNode.getUncached();
@@ -923,8 +928,7 @@ private void initializeImportlib() {
923928
// first, a workaround since postInitialize hasn't run yet for the _weakref module aliases
924929
writeNode.execute(lookupBuiltinModule(T__WEAKREF), T_REF, lookupType(PythonBuiltinClassType.PReferenceType));
925930

926-
if (bootstrap == null) {
927-
// true when the frozen module is not available
931+
if (!useFrozenModules) {
928932
bootstrapExternal = createModule(T_IMPORTLIB_BOOTSTRAP_EXTERNAL);
929933
bootstrap = createModule(T_IMPORTLIB_BOOTSTRAP);
930934
loadFile(toTruffleStringUncached("importlib/_bootstrap_external"), getContext().getStdlibHome(), bootstrapExternal);
@@ -964,11 +968,25 @@ private void initializeImportlib() {
964968
LOGGER.log(Level.FINE, () -> "initializing zipimport failed");
965969
} else {
966970
LOGGER.log(Level.FINE, () -> "# installing zipimport hook");
971+
// when frozen modules are not used, we need to load from file directly
967972
PythonModule zipimport = null;
968973
try {
969-
zipimport = AbstractImportNode.importModule(toTruffleStringUncached("zipimport"));
970-
} catch (PException e) {
971-
LOGGER.log(Level.FINE, () -> "# can't import zipimport");
974+
if (useFrozenModules) {
975+
zipimport = AbstractImportNode.importModule(T_ZIPIMPORT);
976+
} else {
977+
// load zipimport from file, and since postInitialize hasn't run yet we
978+
// cannot use the normal import machinery without frozen modules at this
979+
// point
980+
zipimport = createModule(T_ZIPIMPORT);
981+
loadFile(T_ZIPIMPORT, getContext().getStdlibHome(), zipimport);
982+
setItem.execute(null, null, sysModules, T_ZIPIMPORT, zipimport);
983+
}
984+
} catch (RuntimeException e) {
985+
LOGGER.log(Level.FINE, () -> {
986+
StringWriter tb = new StringWriter();
987+
ExceptionUtils.printPythonLikeStackTrace(new PrintWriter(tb), e);
988+
return tb.toString() + System.lineSeparator() + "# can't import zipimport";
989+
});
972990
}
973991
if (zipimport != null) {
974992
writeNode.execute(zipimport, T___BUILTINS__, getBuiltins());

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/BuiltinNames.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,8 @@ public abstract class BuiltinNames {
302302

303303
public static final TruffleString T___IMPORT__ = tsLiteral("__import__");
304304

305+
public static final TruffleString T_ZIPIMPORT = tsLiteral("zipimport");
306+
305307
public static final String J_COMPLEX = "complex";
306308

307309
public static final String J_HASATTR = "hasattr";

mx.graalpython/mx_graalpython.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -893,10 +893,9 @@ def graalpy_standalone_home(standalone_type, enterprise=False, dev=False, build=
893893
svm_component = '_SVM'
894894
if enterprise:
895895
env_file = 'ee-python'
896-
try:
897-
vm_suite_path = os.path.join(mx.suite('graal-enterprise').dir, '..', 'vm-enterprise')
898-
except:
899-
vm_suite_path = os.path.join(SUITE.dir, '..', 'graal-enterprise', 'vm-enterprise')
896+
enterprise_suite = mx.suite('graal-enterprise', fatalIfMissing=False)
897+
enterprise_suite_dir = enterprise_suite.dir if enterprise_suite else os.path.join(SUITE.dir, '..', 'graal-enterprise', 'graal-enterprise')
898+
vm_suite_path = os.path.join(enterprise_suite_dir, '..', 'vm-enterprise')
900899
svm_component = '_SVM_SVMEE'
901900
if dev:
902901
if standalone_type == 'jvm':
@@ -2570,6 +2569,7 @@ def python_coverage(args):
25702569
else:
25712570
variants = [
25722571
{"args": []},
2572+
{"args": SANDBOXED_OPTIONS},
25732573
{"args": ["--python.EmulateJython"], "paths": ["test_interop.py"]},
25742574
{"hpy": True},
25752575
]

mx.graalpython/suite.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# METADATA
66
#
77
# --------------------------------------------------------------------------------------------------------------
8-
"mxversion": "7.27.0",
8+
"mxversion": "7.33.0",
99
"name": "graalpython",
1010
"versionConflictResolution": "latest",
1111

@@ -45,31 +45,31 @@
4545
},
4646
{
4747
"name": "sdk",
48-
"version": "64d3e5d973f1d1b9c05f2408a7896efbad7d0157",
48+
"version": "3ee833a230e5af859f1289fbe5161a9abf422ec7",
4949
"subdir": True,
5050
"urls": [
5151
{"url": "https://github.com/oracle/graal", "kind": "git"},
5252
]
5353
},
5454
{
5555
"name": "tools",
56-
"version": "64d3e5d973f1d1b9c05f2408a7896efbad7d0157",
56+
"version": "3ee833a230e5af859f1289fbe5161a9abf422ec7",
5757
"subdir": True,
5858
"urls": [
5959
{"url": "https://github.com/oracle/graal", "kind": "git"},
6060
],
6161
},
6262
{
6363
"name": "sulong",
64-
"version": "64d3e5d973f1d1b9c05f2408a7896efbad7d0157",
64+
"version": "3ee833a230e5af859f1289fbe5161a9abf422ec7",
6565
"subdir": True,
6666
"urls": [
6767
{"url": "https://github.com/oracle/graal", "kind": "git"},
6868
]
6969
},
7070
{
7171
"name": "regex",
72-
"version": "64d3e5d973f1d1b9c05f2408a7896efbad7d0157",
72+
"version": "3ee833a230e5af859f1289fbe5161a9abf422ec7",
7373
"subdir": True,
7474
"urls": [
7575
{"url": "https://github.com/oracle/graal", "kind": "git"},

0 commit comments

Comments
 (0)