File tree Expand file tree Collapse file tree 3 files changed +13
-2
lines changed
graalpython/com.oracle.graal.python/src/com/oracle/graal/python Expand file tree Collapse file tree 3 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -112,7 +112,11 @@ public void initialize(PythonCore core) {
112
112
builtinConstants .put ("byteorder" , ByteOrder .nativeOrder () == ByteOrder .LITTLE_ENDIAN ? "little" : "big" );
113
113
builtinConstants .put ("copyright" , LICENSE );
114
114
builtinConstants .put ("dont_write_bytecode" , true );
115
- if (TruffleOptions .AOT || !core .getContext ().isExecutableAccessAllowed ()) {
115
+
116
+ String executable = PythonOptions .getOption (core .getContext (), PythonOptions .ExecutablePath );
117
+ if (!executable .isEmpty () && core .getContext ().isExecutableAccessAllowed ()) {
118
+ builtinConstants .put ("executable" , executable );
119
+ } else if (TruffleOptions .AOT || !core .getContext ().isExecutableAccessAllowed ()) {
116
120
// cannot set the path at this time since the binary is not yet known; will be patched
117
121
// in the context
118
122
builtinConstants .put ("executable" , PNone .NONE );
@@ -140,6 +144,7 @@ public void initialize(PythonCore core) {
140
144
builtinConstants .put ("executable" , sb .toString ());
141
145
builtinConstants .put ("executable_list" , core .factory ().createList (exec_list .toArray ()));
142
146
}
147
+
143
148
builtinConstants .put ("modules" , core .factory ().createDict ());
144
149
builtinConstants .put ("path" , core .factory ().createList ());
145
150
builtinConstants .put ("builtin_module_names" , core .factory ().createTuple (core .builtinModuleNames ()));
Original file line number Diff line number Diff line change 41
41
import org .graalvm .options .OptionValues ;
42
42
43
43
import com .oracle .graal .python .PythonLanguage ;
44
+ import com .oracle .graal .python .builtins .objects .PNone ;
44
45
import com .oracle .graal .python .builtins .objects .bytes .OpaqueBytes ;
45
46
import com .oracle .graal .python .builtins .objects .cext .NativeWrappers .PThreadState ;
46
47
import com .oracle .graal .python .builtins .objects .common .HashingStorage ;
@@ -237,7 +238,9 @@ public void patch(Env newEnv) {
237
238
private void setupRuntimeInformation () {
238
239
PythonModule sysModule = core .initializeSysModule ();
239
240
if (ImageInfo .inImageRuntimeCode () && isExecutableAccessAllowed ()) {
240
- sysModule .setAttribute ("executable" , ProcessProperties .getExecutableName ());
241
+ if (sysModule .getAttribute ("executable" ) == PNone .NONE ) {
242
+ sysModule .setAttribute ("executable" , ProcessProperties .getExecutableName ());
243
+ }
241
244
}
242
245
sysModules = (PDict ) sysModule .getAttribute ("modules" );
243
246
builtinsModule = (PythonModule ) sysModules .getItem ("builtins" );
Original file line number Diff line number Diff line change @@ -128,6 +128,9 @@ private PythonOptions() {
128
128
@ Option (category = OptionCategory .EXPERT , help = "Set by the launcher to the terminal height." ) //
129
129
public static final OptionKey <Integer > TerminalHeight = new OptionKey <>(25 );
130
130
131
+ @ Option (category = OptionCategory .EXPERT , help = "The sys.executable path" ) //
132
+ public static final OptionKey <String > ExecutablePath = new OptionKey <>("" );
133
+
131
134
public static OptionDescriptors createDescriptors () {
132
135
return new PythonOptionsOptionDescriptors ();
133
136
}
You can’t perform that action at this time.
0 commit comments