Skip to content

Commit 815fa64

Browse files
committed
Don't set sys._prefix in main, that's site.py's job
1 parent a04fe4f commit 815fa64

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

graalpython/com.oracle.graal.python.shell/src/com/oracle/graal/python/shell/GraalPythonMain.java

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import java.io.File;
3131
import java.io.FileDescriptor;
3232
import java.io.FileOutputStream;
33-
import java.io.IOError;
3433
import java.io.IOException;
3534
import java.io.InputStream;
3635
import java.io.OutputStream;
@@ -717,8 +716,7 @@ protected void launch(Builder contextBuilder) {
717716
// the user did not explicitly pass some options that would be otherwise loaded from
718717
// pyvenv.cfg. Notable usage of this feature is GraalPython venvs which generate a
719718
// launcher script that passes those options explicitly without relying on pyvenv.cfg
720-
boolean tryVenvCfg = !hasContextOptionSetViaCommandLine("SysPrefix") &&
721-
!hasContextOptionSetViaCommandLine("PythonHome") &&
719+
boolean tryVenvCfg = !hasContextOptionSetViaCommandLine("PythonHome") &&
722720
getEnv("GRAAL_PYTHONHOME") == null;
723721
if (tryVenvCfg) {
724722
findAndApplyVenvCfg(contextBuilder, executable);
@@ -872,6 +870,7 @@ private static String toAbsolutePath(String executable) {
872870
return Paths.get(executable).toAbsolutePath().toString();
873871
}
874872

873+
// Rough equivalent of CPython's pyvenv.cfg logic in Modules/getpath.py
875874
private void findAndApplyVenvCfg(Builder contextBuilder, String executable) {
876875
Path binDir;
877876
try {
@@ -927,16 +926,6 @@ private void findAndApplyVenvCfg(Builder contextBuilder, String executable) {
927926
// NullPointerException covers the possible null result of getParent()
928927
warn("Could not set PYTHONHOME according to the pyvenv.cfg file.");
929928
}
930-
String sysPrefix = null;
931-
try {
932-
sysPrefix = venvCfg.getParent().toAbsolutePath().toString();
933-
} catch (IOError | NullPointerException ex) {
934-
// NullPointerException covers the possible null result of getParent()
935-
warn("Could not set the sys.prefix according to the pyvenv.cfg file.");
936-
}
937-
if (sysPrefix != null) {
938-
contextBuilder.option("python.SysPrefix", sysPrefix);
939-
}
940929
break;
941930
}
942931
}

0 commit comments

Comments
 (0)