| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -96,6 +96,27 @@ internal static int GetRun() | |||
| 96 | 96 | return runNumber; | |
| 97 | 97 | } | |
| 98 | 98 | ||
| 99 | + static void EnsureProgramName() | ||
| 100 | + { | ||
| 101 | + if (!string.IsNullOrEmpty(PythonEngine.ProgramName)) | ||
| 102 | + return; | ||
| 103 | + | ||
| 104 | + string fromEnv = Environment.GetEnvironmentVariable("PYTHONNET_PYEXE"); | ||
| 105 | + if (!string.IsNullOrEmpty(fromEnv)) | ||
| 106 | + { | ||
| 107 | + PythonEngine.ProgramName = fromEnv; | ||
| 108 | + return; | ||
| 109 | + } | ||
| 110 | + | ||
| 111 | + string venv = Environment.GetEnvironmentVariable("VIRTUAL_ENV"); | ||
| 112 | + if (!string.IsNullOrEmpty(venv)) | ||
| 113 | + { | ||
| 114 | + string exeName = IsWindows ? "python.exe" : "python"; | ||
| 115 | + string fullPath = System.IO.Path.Combine(venv, "bin", exeName); | ||
| 116 | + PythonEngine.ProgramName = fullPath; | ||
| 117 | + } | ||
| 118 | + } | ||
| 119 | + | ||
| 99 | 120 | internal static bool HostedInPython; | |
| 100 | 121 | internal static bool ProcessIsTerminating; | |
| 101 | 122 | ||
@@ -117,6 +138,8 @@ internal static void Initialize(bool initSigs = false) | |||
| 117 | 138 | ); | |
| 118 | 139 | if (!interpreterAlreadyInitialized) | |
| 119 | 140 | { | |
| 141 | + EnsureProgramName(); | ||
| 142 | + | ||
| 120 | 143 | Py_InitializeEx(initSigs ? 1 : 0); | |
| 121 | 144 | ||
| 122 | 145 | NewRun(); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments