8000 Implement InitializePlatformData without calling Python · pythonnet/pythonnet@e213a97 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e213a97

Browse files
committed
Implement InitializePlatformData without calling Python
1 parent a9b91a3 commit e213a97

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/runtime/runtime.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ internal static void Initialize(bool initSigs = false)
356356
/// </summary>
357357
private static void InitializePlatformData()
358358
{
359+
#if !NETSTANDARD
359360
IntPtr op;
360361
IntPtr fn;
361362
IntPtr platformModule = PyImport_ImportModule("platform");
@@ -391,6 +392,34 @@ private static void InitializePlatformData()
391392
MType = MachineType.Other;
392393
}
393394
Machine = MType;
395+
#else
396+
OperatingSystem = OperatingSystemType.Other;
397+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
398+
OperatingSystem = OperatingSystemType.Linux;
399+
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
400+
OperatingSystem = OperatingSystemType.Darwin;
401+
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
402+
OperatingSystem = OperatingSystemType.Windows;
403+
404+
switch (RuntimeInformation.ProcessArchitecture)
405+
{
406+
case Architecture.X86:
407+
Machine = MachineType.i386;
408+
break;
409+
case Architecture.X64:
410+
Machine = MachineType.x86_64;
411+
break;
412+
case Architecture.Arm:
413+
Machine = MachineType.armv7l;
414+
break;
415+
case Architecture.Arm64:
416+
Machine = MachineType.aarch64;
417+
break;
418+
default:
419+
Machine = MachineType.Other;
420+
break;
421+
}
422+
#endif
394423
}
395424

396425
internal static void Shutdown()

0 commit comments

Comments
 (0)
0