@@ -26,6 +26,9 @@ public PythonPlugin(string filename)
2626
2727 var path = Path . Combine ( Constant . ProgramDirectory , JsonRPC ) ;
2828 _startInfo . EnvironmentVariables [ "PYTHONPATH" ] = path ;
29+ // Prevent Python from writing .py[co] files.
30+ // Because .pyc contains location infos which will prevent python portable.
31+ _startInfo . EnvironmentVariables [ "PYTHONDONTWRITEBYTECODE" ] = "1" ;
2932
3033 _startInfo . EnvironmentVariables [ "FLOW_VERSION" ] = Constant . Version ;
3134 _startInfo . EnvironmentVariables [ "FLOW_PROGRAM_DIRECTORY" ] = Constant . ProgramDirectory ;
@@ -76,15 +79,13 @@ import runpy
7679 // Plugins always expect the JSON data to be in the third argument
7780 // (we're always setting it as _startInfo.ArgumentList[2] = ...).
7881 _startInfo . ArgumentList . Add ( "" ) ;
79- // Because plugins always expect the JSON data to be in the third argument, and specifying -c <code>
80- // takes up two arguments, we have to move `-B` to the end.
81- _startInfo . ArgumentList . Add ( "-B" ) ;
8282 }
8383 // Run .pyz files as is
8484 else
8585 {
86- // -B flag is needed to tell python not to write .py[co] files.
87- // Because .pyc contains location infos which will prevent python portable
86+ // No need for -B flag because we're using PYTHONDONTWRITEBYTECODE env variable now,
87+ // but the plugins still expect data to be sent as the third argument, so we're keeping
88+ // the flag here, even though it's not necessary anymore.
8889 _startInfo . ArgumentList . Add ( "-B" ) ;
8990 _startInfo . ArgumentList . Add ( context . CurrentPluginMetadata . ExecuteFilePath ) ;
9091 // Plugins always expect the JSON data to be in the third argument
0 commit comments