| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 140a9b8 commit ec424bb
42 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,7 +6,6 @@ python: | |||
| 6 | 6 | - 3.7 | |
| 7 | 7 | - 3.6 | |
| 8 | 8 | - 3.5 | |
| 9 | - - 2.7 | ||
| 10 | 9 | ||
| 11 | 10 | env: | |
| 12 | 11 | matrix: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,6 +10,7 @@ This document follows the conventions laid out in [Keep a CHANGELOG][]. | |||
| 10 | 10 | ### Added | |
| 11 | 11 | ||
| 12 | 12 | ### Changed | |
| 13 | + - Drop support for Python 2 | ||
| 13 | 14 | ||
| 14 | 15 | ### Fixed | |
| 15 | 16 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,7 +3,7 @@ build: off | |||
| 3 | 3 | ||
| 4 | 4 | image: | |
| 5 | 5 | - Visual Studio 2017 | |
| 6 | - | ||
| 6 | + | ||
| 7 | 7 | platform: | |
| 8 | 8 | - x86 | |
| 9 | 9 | - x64 | |
@@ -23,13 +23,10 @@ environment: | |||
| 23 | 23 | BUILD_OPTS: --xplat | |
| 24 | 24 | - PYTHON_VERSION: 3.5 | |
| 25 | 25 | BUILD_OPTS: --xplat | |
| 26 | - - PYTHON_VERSION: 2.7 | ||
| 27 | - BUILD_OPTS: --xplat | ||
| 28 | 26 | - PYTHON_VERSION: 3.8 | |
| 29 | 27 | - PYTHON_VERSION: 3.7 | |
| 30 | 28 | - PYTHON_VERSION: 3.6 | |
| 31 | 29 | - PYTHON_VERSION: 3.5 | |
| 32 | - - PYTHON_VERSION: 2.7 | ||
| 33 | 30 | ||
| 34 | 31 | init: | |
| 35 | 32 | # Update Environment Variables based on matrix/platform | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -150,8 +150,6 @@ | |||
| 150 | 150 | def _check_output(*args, **kwargs): | |
| 151 | 151 | """Check output wrapper for py2/py3 compatibility""" | |
| 152 | 152 | output = subprocess.check_output(*args, **kwargs) | |
| 153 | - if PY_MAJOR == 2: | ||
| 154 | - return output | ||
| 155 | 153 | return output.decode("ascii") | |
| 156 | 154 | ||
| 157 | 155 | ||
@@ -255,17 +253,11 @@ def build_extension(self, ext): | |||
| 255 | 253 | ||
| 256 | 254 | # Up to Python 3.2 sys.maxunicode is used to determine the size of | |
| 257 | 255 | # Py_UNICODE, but from 3.3 onwards Py_UNICODE is a typedef of wchar_t. | |
| 258 | - # TODO: Is this doing the right check for Py27? | ||
| 259 | - if sys.version_info[:2] <= (3, 2): | ||
| 260 | - unicode_width = 2 if sys.maxunicode < 0x10FFFF else 4 | ||
| 261 | - else: | ||
| 262 | - import ctypes | ||
| 263 | - | ||
| 264 | - unicode_width = ctypes.sizeof(ctypes.c_wchar) | ||
| 256 | + import ctypes | ||
| 257 | + unicode_width = ctypes.sizeof(ctypes.c_wchar) | ||
| 265 | 258 | ||
| 266 | 259 | defines = [ | |
| 267 | 260 | "PYTHON{0}{1}".format(PY_MAJOR, PY_MINOR), | |
| 268 | - "PYTHON{0}".format(PY_MAJOR), # Python Major Version | ||
| 269 | 261 | "UCS{0}".format(unicode_width), | |
| 270 | 262 | ] | |
| 271 | 263 | ||
@@ -274,7 +266,6 @@ def build_extension(self, ext): | |||
| 274 | 266 | ||
| 275 | 267 | if sys.platform != "win32" and (DEVTOOLS == "Mono" or DEVTOOLS == "dotnet"): | |
| 276 | 268 | on_darwin = sys.platform == "darwin" | |
| 277 | - defines.append("MONO_OSX" if on_darwin else "MONO_LINUX") | ||
| 278 | 269 | ||
| 279 | 270 | # Check if --enable-shared was set when Python was built | |
| 280 | 271 | enable_shared = sysconfig.get_config_var("Py_ENABLE_SHARED") | |
@@ -288,6 +279,9 @@ def build_extension(self, ext): | |||
| 288 | 279 | if not enable_shared: | |
| 289 | 280 | defines.append("PYTHON_WITHOUT_ENABLE_SHARED") | |
| 290 | 281 | ||
| 282 | + if sys.platform == "win32": | ||
| 283 | + defines.append("WINDOWS") | ||
| 284 | + | ||
| 291 | 285 | if hasattr(sys, "abiflags"): | |
| 292 | 286 | if "d" in sys.abiflags: | |
| 293 | 287 | defines.append("PYTHON_WITH_PYDEBUG") | |
@@ -479,10 +473,7 @@ def _find_msbuild_tool(self, tool="msbuild.exe", use_windows_sdk=False): | |||
| 479 | 473 | return path | |
| 480 | 474 | ||
| 481 | 475 | # Search within registry to find build tools | |
| 482 | - try: # PY2 | ||
| 483 | - import _winreg as winreg | ||
| 484 | - except ImportError: # PY3 | ||
| 485 | - import winreg | ||
| 476 | + import winreg | ||
| 486 | 477 | ||
| 487 | 478 | _collect_installed_windows_kits_v10(winreg) | |
| 488 | 479 | ||
@@ -645,8 +636,6 @@ def run(self): | |||
| 645 | 636 | "Intended Audience :: Developers", | |
| 646 | 637 | "License :: OSI Approved :: MIT License", | |
| 647 | 638 | "Programming Language :: C#", | |
| 648 | - "Programming Language :: Python :: 2", | ||
| 649 | - "Programming Language :: Python :: 2.7", | ||
| 650 | 639 | "Programming Language :: Python :: 3", | |
| 651 | 640 | "Programming Language :: Python :: 3.5", | |
| 652 | 641 | "Programming Language :: Python :: 3.6", | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,13 +30,8 @@ | |||
| 30 | 30 | ||
| 31 | 31 | public class clrModule | |
| 32 | 32 | { | |
| 33 | - #if PYTHON3 | ||
| 34 | 33 | [DllExport("PyInit_clr", CallingConvention.StdCall)] | |
| 35 | 34 | public static IntPtr PyInit_clr() | |
| 36 | - #elif PYTHON2 | ||
| 37 | - [DllExport("initclr", CallingConvention.StdCall)] | ||
| 38 | - public static void initclr() | ||
| 39 | - #endif | ||
| 40 | 35 | { | |
| 41 | 36 | DebugPrint("Attempting to load 'Python.Runtime' using standard binding rules."); | |
| 42 | 37 | #if USE_PYTHON_RUNTIME_PUBLIC_KEY_TOKEN | |
@@ -95,23 +90,15 @@ public static void initclr() | |||
| 95 | 90 | catch (InvalidOperationException) | |
| 96 | 91 | { | |
| 97 | 92 | DebugPrint("Could not load 'Python.Runtime'."); | |
| 98 | - #if PYTHON3 | ||
| 99 | 93 | return IntPtr.Zero; | |
| 100 | - #elif PYTHON2 | ||
| 101 | - return; | ||
| 102 | - #endif | ||
| 103 | 94 | } | |
| 104 | 95 | } | |
| 105 | 96 | ||
| 106 | 97 | // Once here, we've successfully loaded SOME version of Python.Runtime | |
| 107 | 98 | // So now we get the PythonEngine and execute the InitExt method on it. | |
| 108 | 99 | Type pythonEngineType = pythonRuntime.GetType("Python.Runtime.PythonEngine"); | |
| 109 | 100 | ||
| 110 | - #if PYTHON3 | ||
| 111 | 101 | return (IntPtr)pythonEngineType.InvokeMember("InitExt", BindingFlags.InvokeMethod, null, null, null); | |
| 112 | - #elif PYTHON2 | ||
| 113 | - pythonEngineType.InvokeMember("InitExt", BindingFlags.InvokeMethod, null, null, null); | ||
| 114 | - #endif | ||
| 115 | 102 | } | |
| 116 | 103 | ||
| 117 | 104 | /// <summary> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25,9 +25,7 @@ public void TestNoOverloadException() { | |||
| 25 | 25 | dynamic callWith42 = PythonEngine.Eval("lambda f: f([42])"); | |
| 26 | 26 | var error = Assert.Throws<PythonException>(() => callWith42(aFunctionThatCallsIntoPython.ToPython())); | |
| 27 | 27 | Assert.AreEqual("TypeError", error.PythonTypeName); | |
| 28 | - string expectedArgTypes = Runtime.IsPython2 | ||
| 29 | - ? "(<type 'list'>)" | ||
| 30 | - : "(<class 'list'>)"; | ||
| 28 | + string expectedArgTypes = "(<class 'list'>)"; | ||
| 31 | 29 | StringAssert.EndsWith(expectedArgTypes, error.Message); | |
| 32 | 30 | } | |
| 33 | 31 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -180,12 +180,6 @@ public void SetProgramName() | |||
| 180 | 180 | [Test] | |
| 181 | 181 | public void SetPythonPath() | |
| 182 | 182 | { | |
| 183 | - if (Runtime.Runtime.pyversion == "2.7") | ||
| 184 | - { | ||
| 185 | - // Assert.Skip outputs as a warning (ie. pending to fix) | ||
| 186 | - Assert.Pass(); | ||
| 187 | - } | ||
| 188 | - | ||
| 189 | 183 | PythonEngine.Initialize(); | |
| 190 | 184 | string path = PythonEngine.PythonPath; | |
| 191 | 185 | PythonEngine.Shutdown(); | |
@@ -196,25 +190,5 @@ public void SetPythonPath() | |||
| 196 | 190 | Assert.AreEqual(path, PythonEngine.PythonPath); | |
| 197 | 191 | PythonEngine.Shutdown(); | |
| 198 | 192 | } | |
| 199 | - | ||
| 200 | - [Test] | ||
| 201 | - public void SetPythonPathExceptionOn27() | ||
| 202 | - { | ||
| 203 | - if (Runtime.Runtime.pyversion != "2.7") | ||
| 204 | - { | ||
| 205 | - Assert.Pass(); | ||
| 206 | - } | ||
| 207 | - | ||
| 208 | - PythonEngine.Initialize(); | ||
| 209 | - string path = PythonEngine.PythonPath; | ||
| 210 | - PythonEngine.Shutdown(); | ||
| 211 | - | ||
| 212 | - var ex = Assert.Throws<NotSupportedException>(() => PythonEngine.PythonPath = "foo"); | ||
| 213 | - Assert.AreEqual("Set PythonPath not supported on Python 2", ex.Message); | ||
| 214 | - | ||
| 215 | - PythonEngine.Initialize(); | ||
| 216 | - Assert.AreEqual(path, PythonEngine.PythonPath); | ||
| 217 | - PythonEngine.Shutdown(); | ||
| 218 | - } | ||
| 219 | 193 | } | |
| 220 | 194 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -120,9 +120,7 @@ public static int GetUnicodeByteLength(IntPtr p) | |||
| 120 | 120 | /// </remarks> | |
| 121 | 121 | public static IntPtr Py3UnicodePy2StringtoPtr(string s) | |
| 122 | 122 | { | |
| 123 | - return Runtime.IsPython3 | ||
| 124 | - ? Instance.MarshalManagedToNative(s) | ||
| 125 | - : Marshal.StringToHGlobalAnsi(s); | ||
| 123 | + return Instance.MarshalManagedToNative(s); | ||
| 126 | 124 | } | |
| 127 | 125 | ||
| 128 | 126 | /// <summary> | |
@@ -137,9 +135,7 @@ public static IntPtr Py3UnicodePy2StringtoPtr(string s) | |||
| 137 | 135 | /// </returns> | |
| 138 | 136 | public static string PtrToPy3UnicodePy2String(IntPtr p) | |
| 139 | 137 | { | |
| 140 | - return Runtime.IsPython3 | ||
| 141 | - ? PtrToStringUni(p) | ||
| 142 | - : Marshal.PtrToStringAnsi(p); | ||
| 138 | + return PtrToStringUni(p); | ||
| 143 | 139 | } | |
| 144 | 140 | } | |
| 145 | 141 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments