| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -167,7 +167,8 @@ static PythonEnvironment TryDetectEnvironmentFromInterpreter(string potentialInt | |||
| 167 | 167 | if (dll != null && !File.Exists(dll)) | |
| 168 | 168 | dll = null; | |
| 169 | 169 | } | |
| 170 | - if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)){ | ||
| 170 | + if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) | ||
| 171 | + || RuntimeInformation.IsOSPlatform(OSPlatform.OSX)){ | ||
| 171 | 172 | dll = TryLocateSo(potentialInterpreter); | |
| 172 | 173 | } | |
| 173 | 174 | return home != null || dll != null | |
@@ -178,23 +179,31 @@ static PythonEnvironment TryDetectEnvironmentFromInterpreter(string potentialInt | |||
| 178 | 179 | } | |
| 179 | 180 | ||
| 180 | 181 | static string TryLocateSo(string interpreterPath) { | |
| 181 | - var getMemMapStartInfo = new ProcessStartInfo(interpreterPath, $"-c \"{GetMemMapScript}\""){ | ||
| 182 | + string getLibPathsScript = RuntimeInformation.IsOSPlatform(OSPlatform.Linux) | ||
| 183 | + ? LinuxGetLibPathsScript | ||
| 184 | + : MacGetLibPathsScript; | ||
| 185 | + var getLibPathsStartInfo = new ProcessStartInfo(interpreterPath, $"-c \"{getLibPathsScript}\""){ | ||
| 182 | 186 | CreateNoWindow = true, | |
| 183 | 187 | RedirectStandardOutput = true, | |
| 184 | 188 | UseShellExecute = false, | |
| 185 | 189 | }; | |
| 186 | 190 | ||
| 187 | 191 | try{ | |
| 188 | - var getMemMap = Process.Start(getMemMapStartInfo); | ||
| 189 | - if (!getMemMap.WaitForExit(5000)){ | ||
| 190 | - getMemMap.Kill(); | ||
| 192 | + var getLibPaths = Process.Start(getLibPathsStartInfo); | ||
| 193 | + if (!getLibPaths.WaitForExit(5000)){ | ||
| 194 | + getLibPaths.Kill(); | ||
| 191 | 195 | return null; | |
| 192 | 196 | } | |
| 193 | - string stdout = getMemMap.StandardOutput.ReadToEnd(); | ||
| 197 | + string stdout = getLibPaths.StandardOutput.ReadToEnd(); | ||
| 194 | 198 | string[] paths = stdout | |
| 195 | 199 | .Split(new []{Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries) | |
| 196 | 200 | .ToArray(); | |
| 197 | - if (paths.Length == 1) return paths[0]; | ||
| 201 | + if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) | ||
| 202 | + if (paths.Length == 1) return paths[0]; | ||
| 203 | + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { | ||
| 204 | + return paths.Select(libPath => Path.ChangeExtension(libPath, ".dylib")) | ||
| 205 | + .FirstOrDefault(File.Exists); | ||
| 206 | + } | ||
| 198 | 207 | return null; | |
| 199 | 208 | } catch(PlatformNotSupportedException) { | |
| 200 | 209 | return null; | |
@@ -203,6 +212,7 @@ static string TryLocateSo(string interpreterPath) { | |||
| 203 | 212 | } | |
| 204 | 213 | } | |
| 205 | 214 | ||
| 206 | - const string GetMemMapScript = @"from distutils import sysconfig; import os.path as op; v = sysconfig.get_config_vars(); fpaths = [op.join(v[pv], v['LDLIBRARY']) for pv in ('LIBDIR', 'LIBPL')]; print(list(filter(op.exists, fpaths))[0])"; | ||
| 215 | + const string LinuxGetLibPathsScript = @"from distutils import sysconfig; import os.path as op; v = sysconfig.get_config_vars(); fpaths = [op.join(v[pv], v['LDLIBRARY']) for pv in ('LIBDIR', 'LIBPL')]; print(list(filter(op.exists, fpaths))[0])"; | ||
| 216 | + const string MacGetLibPathsScript = @"from distutils import sysconfig; import os.path as op; v = sysconfig.get_config_vars(); fpaths = [op.join(v[pv], v['LIBRARY']) for pv in ('LIBDIR', 'LIBPL')]; print(list(filter(op.exists, fpaths))[0])"; | ||
| 207 | 217 | } | |
| 208 | 218 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments