From f80cd0899309d6b1431f3fa1befb9d8717c46619 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 4 Aug 2023 14:20:59 +0200 Subject: [PATCH] Remove support for EOL Python versions 3.6 and 3.7 --- .github/workflows/ci.yml | 46 -------------------- direct/src/showbase/ContainerLeakDetector.py | 3 +- direct/src/showbase/ContainerReport.py | 3 +- makepanda/makepanda.py | 4 +- makepanda/makepandacore.py | 19 ++------ makepanda/makewheel.py | 19 ++------ panda/src/event/asyncFuture_ext.cxx | 20 --------- setup.cfg | 2 - tests/dtoolutil/test_filename.py | 2 - tests/event/test_futures.py | 6 +-- tests/pgraph/test_loader_types.py | 1 - 11 files changed, 11 insertions(+), 114 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bfddcd515e..f6ffb17719 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -180,38 +180,6 @@ jobs: run: cmake --build . --config ${{ matrix.config }} --parallel 4 # END A - - name: Setup Python (Python 3.7) - if: contains(matrix.python, 'YES') - uses: actions/setup-python@v4 - with: - python-version: '3.7' - - name: Configure (Python 3.7) - if: contains(matrix.python, 'YES') - working-directory: build - shell: bash - run: > - cmake -DWANT_PYTHON_VERSION=3.7 -DHAVE_PYTHON=YES - -DPython_FIND_REGISTRY=NEVER -DPython_ROOT="$pythonLocation" . - - name: Build (Python 3.7) - if: contains(matrix.python, 'YES') - # BEGIN A - working-directory: build - run: cmake --build . --config ${{ matrix.config }} --parallel 4 - # END A - - name: Test (Python 3.7) - # BEGIN B - if: contains(matrix.python, 'YES') - working-directory: build - shell: bash - env: - PYTHONPATH: ${{ matrix.config }} - run: | - PYTHON_EXECUTABLE=$(grep 'Python_EXECUTABLE:' CMakeCache.txt | sed 's/.*=//') - $PYTHON_EXECUTABLE -m pip install -r ../requirements-test.txt - export COVERAGE_FILE=.coverage.$RANDOM LLVM_PROFILE_FILE=$PWD/pid-%p.profraw - $PYTHON_EXECUTABLE -m pytest ../tests --cov=. - # END B - - name: Setup Python (Python 3.8) if: contains(matrix.python, 'YES') uses: actions/setup-python@v4 @@ -443,20 +411,6 @@ jobs: python -m pip install -r requirements-test.txt PYTHONPATH=built LD_LIBRARY_PATH=built/lib DYLD_LIBRARY_PATH=built/lib python -m pytest - - name: Set up Python 3.7 - uses: actions/setup-python@v4 - with: - python-version: '3.7' - - name: Build Python 3.7 - shell: bash - run: | - python makepanda/makepanda.py --git-commit=${{github.sha}} --outputdir=built --everything --no-eigen --python-incdir="$pythonLocation/include" --python-libdir="$pythonLocation/lib" --verbose --threads=4 --windows-sdk=10 - - name: Test Python 3.7 - shell: bash - run: | - python -m pip install -r requirements-test.txt - PYTHONPATH=built LD_LIBRARY_PATH=built/lib DYLD_LIBRARY_PATH=built/lib python -m pytest - - name: Make installer run: | python makepanda/makepackage.py --verbose --lzma diff --git a/direct/src/showbase/ContainerLeakDetector.py b/direct/src/showbase/ContainerLeakDetector.py index b172cbb4e3..ef1949f33c 100755 --- a/direct/src/showbase/ContainerLeakDetector.py +++ b/direct/src/showbase/ContainerLeakDetector.py @@ -11,7 +11,6 @@ import types import weakref import random import builtins -import sys deadEndTypes = frozenset(( @@ -566,7 +565,7 @@ class FindContainers(Job): curObjRef = None # types.CellType was added in Python 3.8 - if sys.version_info >= (3, 8) and type(curObj) is types.CellType: + if type(curObj) is types.CellType: child = curObj.cell_contents hasLength = self._hasLength(child) notDeadEnd = not self._isDeadEnd(child) diff --git a/direct/src/showbase/ContainerReport.py b/direct/src/showbase/ContainerReport.py index 6ceca73d07..71468bfbf6 100755 --- a/direct/src/showbase/ContainerReport.py +++ b/direct/src/showbase/ContainerReport.py @@ -5,7 +5,6 @@ from direct.showbase.Job import Job from direct.showbase.JobManagerGlobal import jobMgr from direct.showbase.ContainerLeakDetector import deadEndTypes import types -import sys import io @@ -122,7 +121,7 @@ class ContainerReport(Job): continue # types.CellType was added in Python 3.8 - if sys.version_info >= (3, 8) and type(parentObj) is types.CellType: + if type(parentObj) is types.CellType: child = parentObj.cell_contents if self._examine(child): assert (self._queue.back() is child) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 3ee9778097..1efb46cf21 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -9,8 +9,8 @@ ######################################################################## import sys -if sys.version_info < (3, 6): - print("This version of Python is not supported, use version 3.6 or higher.") +if sys.version_info < (3, 8): + print("This version of Python is not supported, use version 3.8 or higher.") exit(1) try: diff --git a/makepanda/makepandacore.py b/makepanda/makepandacore.py index 8096af175c..964914c1fb 100644 --- a/makepanda/makepandacore.py +++ b/makepanda/makepandacore.py @@ -3390,20 +3390,7 @@ def GetPythonABI(): if soabi: return soabi - soabi = 'cpython-%d%d' % (sys.version_info[:2]) - - if sys.version_info >= (3, 8): - return soabi - - debug_flag = sysconfig.get_config_var('Py_DEBUG') - if (debug_flag is None and hasattr(sys, 'gettotalrefcount')) or debug_flag: - soabi += 'd' - - malloc_flag = sysconfig.get_config_var('WITH_PYMALLOC') - if malloc_flag is None or malloc_flag: - soabi += 'm' - - return soabi + return 'cpython-%d%d' % (sys.version_info[:2]) def CalcLocation(fn, ipath): if fn.startswith("panda3d/") and fn.endswith(".py"): @@ -3545,7 +3532,7 @@ def UpdatePythonVersionInfoFile(new_info): version_info["soabi"] == new_info["soabi"] or \ not os.path.isfile(core_pyd) or \ version_info["version"].split(".", 1)[0] == "2" or \ - version_info["version"] in ("3.0", "3.1", "3.2", "3.3", "3.4", "3.5"): + version_info["version"] in ("3.0", "3.1", "3.2", "3.3", "3.4", "3.5", "3.6", "3.7"): json_data.remove(version_info) if not PkgSkip("PYTHON"): @@ -3570,7 +3557,7 @@ def ReadPythonVersionInfoFile(): # Don't include unsupported versions of Python. for version_info in json_data[:]: - if version_info["version"] in ("2.6", "2.7", "3.0", "3.1", "3.2", "3.3", "3.4"): + if version_info["version"] in ("2.6", "2.7", "3.0", "3.1", "3.2", "3.3", "3.4", "3.5", "3.6", "3.7"): json_data.remove(version_info) return json_data diff --git a/makepanda/makewheel.py b/makepanda/makewheel.py index d770fd2a4e..5b647e6a7c 100644 --- a/makepanda/makewheel.py +++ b/makepanda/makewheel.py @@ -24,20 +24,7 @@ def get_abi_tag(): elif soabi: return soabi.replace('.', '_').replace('-', '_') - soabi = 'cp%d%d' % (sys.version_info[:2]) - - if sys.version_info >= (3, 8): - return soabi - - debug_flag = get_config_var('Py_DEBUG') - if (debug_flag is None and hasattr(sys, 'gettotalrefcount')) or debug_flag: - soabi += 'd' - - malloc_flag = get_config_var('WITH_PYMALLOC') - if malloc_flag is None or malloc_flag: - soabi += 'm' - - return soabi + return 'cp%d%d' % (sys.version_info[:2]) def is_exe_file(path): @@ -635,8 +622,8 @@ def makewheel(version, output_dir, platform=None): if not LocateBinary("patchelf"): raise Exception("patchelf is required when building a Linux wheel.") - if sys.version_info < (3, 6): - raise Exception("Python 3.6 or higher is required to produce a wheel.") + if sys.version_info < (3, 8): + raise Exception("Python 3.8 or higher is required to produce a wheel.") if platform is None: # Determine the platform from the build. diff --git a/panda/src/event/asyncFuture_ext.cxx b/panda/src/event/asyncFuture_ext.cxx index 45a736fe19..eaed216bfe 100644 --- a/panda/src/event/asyncFuture_ext.cxx +++ b/panda/src/event/asyncFuture_ext.cxx @@ -275,11 +275,7 @@ result(PyObject *self, PyObject *timeout) const { static PyObject *exc_type = nullptr; if (exc_type == nullptr) { // Get the TimeoutError that asyncio uses, too. -#if PY_VERSION_HEX >= 0x03080000 PyObject *module = PyImport_ImportModule("asyncio.exceptions"); -#else - PyObject *module = PyImport_ImportModule("concurrent.futures._base"); -#endif if (module != nullptr) { exc_type = PyObject_GetAttrString(module, "TimeoutError"); Py_DECREF(module); @@ -289,15 +285,9 @@ result(PyObject *self, PyObject *timeout) const { } // If we can't get that, we should pretend and make our own. if (exc_type == nullptr) { -#if PY_VERSION_HEX >= 0x03080000 exc_type = PyErr_NewExceptionWithDoc((char*)"asyncio.exceptions.TimeoutError", (char*)"The operation exceeded the given deadline.", nullptr, nullptr); -#else - exc_type = PyErr_NewExceptionWithDoc((char*)"concurrent.futures._base.TimeoutError", - (char*)"The operation exceeded the given deadline.", - nullptr, nullptr); -#endif } } PyErr_SetNone(exc_type); @@ -403,11 +393,7 @@ get_cancelled_error_type() { PyErr_Fetch(&curexc_type, &curexc_value, &curexc_traceback); // Get the CancelledError that asyncio uses, too. -#if PY_VERSION_HEX >= 0x03080000 PyObject *module = PyImport_ImportModule("asyncio.exceptions"); -#else - PyObject *module = PyImport_ImportModule("concurrent.futures._base"); -#endif if (module != nullptr) { exc_type = PyObject_GetAttrString(module, "CancelledError"); Py_DECREF(module); @@ -415,15 +401,9 @@ get_cancelled_error_type() { // If we can't get that, we should pretend and make our own. if (exc_type == nullptr) { -#if PY_VERSION_HEX >= 0x03080000 exc_type = PyErr_NewExceptionWithDoc((char *)"asyncio.exceptions.CancelledError", (char *)"The Future or Task was cancelled.", PyExc_BaseException, nullptr); -#else - exc_type = PyErr_NewExceptionWithDoc((char *)"concurrent.futures._base.CancelledError", - (char *)"The Future was cancelled.", - nullptr, nullptr); -#endif } PyErr_Restore(curexc_type, curexc_value, curexc_traceback); diff --git a/setup.cfg b/setup.cfg index 993e2f1108..50078db334 100644 --- a/setup.cfg +++ b/setup.cfg @@ -14,8 +14,6 @@ classifiers = Programming Language :: C++ Programming Language :: Python Programming Language :: Python :: 3 - Programming Language :: Python :: 3.6 - Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 diff --git a/tests/dtoolutil/test_filename.py b/tests/dtoolutil/test_filename.py index d1a6fe5dd4..13692e0784 100644 --- a/tests/dtoolutil/test_filename.py +++ b/tests/dtoolutil/test_filename.py @@ -3,13 +3,11 @@ import sys, os import pytest -@pytest.mark.skipif(sys.version_info < (3, 6), reason="Requires Python 3.6") def test_filename_fspath(): fn = Filename.from_os_specific(__file__) assert os.fspath(fn) == fn.to_os_specific_w() -@pytest.mark.skipif(sys.version_info < (3, 6), reason="Requires Python 3.6") def test_filename_open(): fn = Filename.from_os_specific(__file__) open(fn, 'rb') diff --git a/tests/event/test_futures.py b/tests/event/test_futures.py index 3bc1ede617..fb5c1626cf 100644 --- a/tests/event/test_futures.py +++ b/tests/event/test_futures.py @@ -2,11 +2,7 @@ from panda3d import core import pytest import time import sys - -if sys.version_info >= (3, 8): - from asyncio.exceptions import TimeoutError, CancelledError -else: - from concurrent.futures._base import TimeoutError, CancelledError +from asyncio.exceptions import TimeoutError, CancelledError class MockFuture: diff --git a/tests/pgraph/test_loader_types.py b/tests/pgraph/test_loader_types.py index 2a0114852f..672cf94680 100644 --- a/tests/pgraph/test_loader_types.py +++ b/tests/pgraph/test_loader_types.py @@ -221,7 +221,6 @@ def test_loader_ram_cache(test_filename): ModelPool.release_model(model2) -@pytest.mark.skipif(sys.version_info < (3, 4), reason="Requires Python 3.4") def test_loader_file_type_registry_pickle(): from direct.stdpy.pickle import dumps, loads