Skip to content
This repository was archived by the owner on Jul 22, 2023. It is now read-only.

Commit 044edfe

Browse files
committed
Refactor runtime's dllBase
As long as the API doesn't change on new python minor releases, all changes needed for new minor versions is isolated to a small section of code.
1 parent 9650e8b commit 044edfe

File tree

1 file changed

+11
-33
lines changed

1 file changed

+11
-33
lines changed

src/runtime/runtime.cs

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -102,54 +102,30 @@ public class Runtime
102102

103103
#if PYTHON27
104104
public const string pyversion = "2.7";
105-
public const int pyversionnumber = 27;
105+
public const string pyver = "27";
106106
#elif PYTHON33
107107
public const string pyversion = "3.3";
108-
public const int pyversionnumber = 33;
108+
public const string pyver = "33";
109109
#elif PYTHON34
110110
public const string pyversion = "3.4";
111-
public const int pyversionnumber = 34;
111+
public const string pyver = "34";
112112
#elif PYTHON35
113113
public const string pyversion = "3.5";
114-
public const int pyversionnumber = 35;
114+
public const string pyver = "35";
115115
#elif PYTHON36
116116
public const string pyversion = "3.6";
117-
public const int pyversionnumber = 36;
117+
public const string pyver = "36";
118118
#elif PYTHON37 // TODO: Add interop37 after Python3.7 is released
119119
public const string pyversion = "3.7";
120-
public const int pyversionnumber = 37;
120+
public const string pyver = "37";
121121
#else
122122
#error You must define one of PYTHON33 to PYTHON37 or PYTHON27
123123
#endif
124124

125-
#if MONO_LINUX || MONO_OSX
126-
#if PYTHON27
127-
internal const string dllBase = "python2.7";
128-
#elif PYTHON33
129-
internal const string dllBase = "python3.3";
130-
#elif PYTHON34
131-
internal const string dllBase = "python3.4";
132-
#elif PYTHON35
133-
internal const string dllBase = "python3.5";
134-
#elif PYTHON36
135-
internal const string dllBase = "python3.6";
136-
#elif PYTHON37
137-
internal const string dllBase = "python3.7";
138-
#endif
125+
#if MONO_LINUX || MONO_OSX // Linux/macOS use dotted version string
126+
internal const string dllBase = "python" + pyversion;
139127
#else // Windows
140-
#if PYTHON27
141-
internal const string dllBase = "python27";
142-
#elif PYTHON33
143-
internal const string dllBase = "python33";
144-
#elif PYTHON34
145-
internal const string dllBase = "python34";
146-
#elif PYTHON35
147-
internal const string dllBase = "python35";
148-
#elif PYTHON36
149-
internal const string dllBase = "python36";
150-
#elif PYTHON37
151-
internal const string dllBase = "python37";
152-
#endif
128+
internal const string dllBase = "python" + pyver;
153129
#endif
154130

155131
#if PYTHON_WITH_PYDEBUG
@@ -174,6 +150,8 @@ public class Runtime
174150
public const string PythonDll = dllBase + dllWithPyDebug + dllWithPyMalloc + dllWithWideUnicode;
175151
#endif
176152

153+
public static readonly int pyversionnumber = Convert.ToInt32(pyver);
154+
177155
// set to true when python is finalizing
178156
internal static object IsFinalizingLock = new object();
179157
internal static bool IsFinalizing = false;

0 commit comments

Comments
 (0)