@@ -26,56 +26,7 @@ public static partial class Runtime
26
26
27
27
internal static bool Is32Bit = IntPtr . Size == 4 ;
28
28
29
- // .NET core: System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
30
- internal static bool IsWindows = Environment . OSVersion . Platform == PlatformID . Win32NT ;
31
-
32
- static readonly Dictionary < string , OperatingSystemType > OperatingSystemTypeMapping = new Dictionary < string , OperatingSystemType > ( )
33
- {
34
- { "Windows" , OperatingSystemType . Windows } ,
35
- { "Darwin" , OperatingSystemType . Darwin } ,
36
- { "Linux" , OperatingSystemType . Linux } ,
37
- } ;
38
-
39
- /// <summary>
40
- /// Gets the operating system as reported by python's platform.system().
41
- /// </summary>
42
- public static OperatingSystemType OperatingSystem { get ; private set ; }
43
-
44
- /// <summary>
45
- /// Gets the operating system as reported by python's platform.system().
46
- /// </summary>
47
- public static string OperatingSystemName { get ; private set ; }
48
-
49
-
50
- /// <summary>
51
- /// Map lower-case version of the python machine name to the processor
52
- /// type. There are aliases, e.g. x86_64 and amd64 are two names for
53
- /// the same thing. Make sure to lower-case the search string, because
54
- /// capitalization can differ.
55
- /// </summary>
56
- static readonly Dictionary < string , MachineType > MachineTypeMapping = new Dictionary < string , MachineType > ( )
57
- {
58
- [ "i386" ] = MachineType . i386 ,
59
- [ "i686" ] = MachineType . i386 ,
60
- [ "x86" ] = MachineType . i386 ,
61
- [ "x86_64" ] = MachineType . x86_64 ,
62
- [ "amd64" ] = MachineType . x86_64 ,
63
- [ "x64" ] = MachineType . x86_64 ,
64
- [ "em64t" ] = MachineType . x86_64 ,
65
- [ "armv7l" ] = MachineType . armv7l ,
66
- [ "armv8" ] = MachineType . armv8 ,
67
- [ "aarch64" ] = MachineType . aarch64 ,
68
- } ;
69
-
70
- /// <summary>
71
- /// Gets the machine architecture as reported by python's platform.machine().
72
- /// </summary>
73
- public static MachineType Machine { get ; private set ; } /* set in Initialize using python's platform.machine */
74
-
75
- /// <summary>
76
- /// Gets the machine architecture as reported by python's platform.machine().
77
- /// </summary>
78
- public static string MachineName { get ; private set ; }
29
+ internal static bool IsWindows = RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) ;
79
30
80
31
#if PYTHON2
81
32
internal static bool IsPython2 = true ;
@@ -221,13 +172,8 @@ internal static void Initialize(bool initSigs = false)
221
172
222
173
Error = new IntPtr ( - 1 ) ;
223
174
224
- // Initialize data about the platform we're running on. We need
225
- // this for the type manager and potentially other details. Must
226
- // happen after caching the python types, above.
227
- InitializePlatformData ( ) ;
228
-
229
175
IntPtr dllLocal = IntPtr . Zero ;
230
- var loader = LibraryLoader . Get ( OperatingSystem ) ;
176
+ var loader = LibraryLoader . Instance ;
231
177
232
178
_PyObject_NextNotImplemented = loader . GetFunction ( dllLocal , "_PyObject_NextNotImplemented" ) ;
233
179
PyModuleType = loader . GetFunction ( dllLocal , "PyModule_Type" ) ;
@@ -248,53 +194,6 @@ internal static void Initialize(bool initSigs = false)
248
194
AssemblyManager . UpdatePath ( ) ;
249
195
}
250
196
251
- /// <summary>
252
- /// Initializes the data about platforms.
253
- ///
254
- /// This must be the last step when initializing the runtime:
255
- /// GetManagedString needs to have the cached values for types.
256
- /// But it must run before initializing anything outside the runtime
257
- /// because those rely on the platform data.
258
- /// </summary>
259
- private static void InitializePlatformData ( )
260
- {
261
- IntPtr op ;
262
- IntPtr fn ;
263
- IntPtr platformModule = PyImport_ImportModule ( "platform" ) ;
264
- IntPtr emptyTuple = PyTuple_New ( 0 ) ;
265
-
266
- fn = PyObject_GetAttrString ( platformModule , "system" ) ;
267
- op = PyObject_Call ( fn , emptyTuple , IntPtr . Zero ) ;
268
- OperatingSystemName = GetManagedString ( op ) ;
269
- XDecref ( op ) ;
270
- XDecref ( fn ) ;
271
-
272
- fn = PyObject_GetAttrString ( platformModule , "machine" ) ;
273
- op = PyObject_Call ( fn , emptyTuple , IntPtr . Zero ) ;
274
- MachineName = GetManagedString ( op ) ;
275
- XDecref ( op ) ;
276
- XDecref ( fn ) ;
277
-
278
- XDecref ( emptyTuple ) ;
279
- XDecref ( platformModule ) ;
280
-
281
- // Now convert the strings into enum values so we can do switch
282
- // statements rather than constant parsing.
283
- OperatingSystemType OSType ;
284
- if ( ! OperatingSystemTypeMapping . TryGetValue ( OperatingSystemName , out OSType ) )
285
- {
286
- OSType = OperatingSystemType . Other ;
287
- }
288
- OperatingSystem = OSType ;
289
-
290
- MachineType MType ;
291
- if ( ! MachineTypeMapping . TryGetValue ( MachineName . ToLower ( ) , out MType ) )
292
- {
293
- MType = MachineType . Other ;
294
- }
295
- Machine = MType ;
296
- }
297
-
298
197
internal static void Shutdown ( )
299
198
{
300
199
AssemblyManager . Shutdown ( ) ;
0 commit comments