@@ -167,9 +167,11 @@ protected List<String> preprocessArguments(List<String> givenArgs, Map<String, S
167167 polyglotGet (launcherName , givenArgs );
168168 }
169169 ArrayList <String > unrecognized = new ArrayList <>();
170- List <String > defaultEnvironmentArgs = getDefaultEnvironmentArgs ();
171- ArrayList <String > inputArgs = new ArrayList <>(givenArgs );
172- inputArgs .addAll (defaultEnvironmentArgs );
170+ List <String > envVmArgs = getDefaultEnvironmentArgs ("GRAAL_PYTHON_VM_ARGS" );
171+ List <String > envArgs = getDefaultEnvironmentArgs ("GRAAL_PYTHON_ARGS" );
172+ ArrayList <String > inputArgs = new ArrayList <>(envVmArgs );
173+ inputArgs .addAll (givenArgs );
174+ inputArgs .addAll (envArgs );
173175 givenArguments = new ArrayList <>(inputArgs );
174176 List <String > arguments = new ArrayList <>(inputArgs );
175177 List <String > subprocessArgs = new ArrayList <>();
@@ -1133,7 +1135,7 @@ protected void printHelp(OptionCategory maxCategory) {
11331135 " in the range [0,4294967295] to get hash values with a predictable seed.\n " +
11341136 "PYTHONPYCACHEPREFIX: if this is set, GraalPython will write .pyc files in a mirror\n " +
11351137 " directory tree at this path, instead of in __pycache__ directories within the source tree.\n " +
1136- "GRAAL_PYTHON_ARGS: the value is added as arguments as if passed on the\n " +
1138+ "GRAAL_PYTHON_ARGS: the value is added as arguments as if passed at the end of the\n " +
11371139 " commandline. Arguments are split on whitespace - you can use \" and/or ' as required to\n " +
11381140 " group them. Alternatively, if the value starts with a vertical tab character, the entire\n " +
11391141 " value is split at vertical tabs and the elements are used as arguments without any further\n " +
@@ -1143,6 +1145,8 @@ protected void printHelp(OptionCategory maxCategory) {
11431145 " with the current process id, and any $UUID$ is replaced with random unique string\n " +
11441146 " that may contain letters, digits, and '-'. To pass a literal `$$', you must escape the\n " +
11451147 " second `$' like so: `$\\ $'\n " +
1148+ "GRAAL_PYTHON_VM_ARGS: the value is prepended as arguments as if passed at the beginning\n " +
1149+ " of the commandline. See GRAAL_PYTHON_ARGS for details.\n " +
11461150 (wantsExperimental ? "\n Arguments specific to the Graal Python launcher:\n " +
11471151 "--show-version : print the Python version number and continue.\n " +
11481152 "-CC : run the C compiler used for generating GraalPython C extensions.\n " +
@@ -1462,15 +1466,15 @@ private static enum State {
14621466 VTAB_DELIMITED ,
14631467 }
14641468
1465- private static List <String > getDefaultEnvironmentArgs () {
1469+ private static List <String > getDefaultEnvironmentArgs (String envName ) {
14661470 String pid ;
14671471 if (isAOT ()) {
14681472 pid = String .valueOf (ProcessProperties .getProcessID ());
14691473 } else {
14701474 pid = ManagementFactory .getRuntimeMXBean ().getName ().split ("@" )[0 ];
14711475 }
14721476 String uuid = UUID .randomUUID ().toString ();
1473- String envArgsOpt = getEnv ("GRAAL_PYTHON_ARGS" );
1477+ String envArgsOpt = getEnv (envName );
14741478 ArrayList <String > envArgs = new ArrayList <>();
14751479 if (envArgsOpt != null ) {
14761480 State s = State .NORMAL ;
0 commit comments