From 68508337e17378e27d11810624f0ccc27ba3fec5 Mon Sep 17 00:00:00 2001 From: Jay Chung Date: Thu, 12 Oct 2023 18:03:27 +0800 Subject: [PATCH 1/4] chore: Support python 3.12 https://www.python.org/downloads/release/python-3120/ --- .github/workflows/ci.yaml | 4 +++- .gitignore | 1 + CONTRIBUTING.md | 4 ++-- setup.cfg | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1cf52b0f..6a017031 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -76,7 +76,7 @@ jobs: matrix: # YAML parse `3.10` to `3.1`, so we have to add quotes for `'3.10'`, see also: # https://github.com/actions/setup-python/issues/160#issuecomment-724485470 - python-version: ['3.6', '3.7', '3.8', '3.9', '3.10', '3.11'] + python-version: ['3.6', '3.7', '3.8', '3.9', '3.10', '3.11', '3.12'] # FIXME: temp change os to ubuntu-20.04 to fix python can not found error https://github.com/actions/setup-python/issues/162#issuecomment-1325307787 os: [ubuntu-20.04, macOS-latest, windows-latest] # Skip because dependence [py4j](https://pypi.org/project/py4j/) not work on those environments @@ -85,6 +85,8 @@ jobs: python-version: '3.10' - os: windows-latest python-version: 3.11 + - os: windows-latest + python-version: 3.12 steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} diff --git a/.gitignore b/.gitignore index 41603809..0c959f5b 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ .vscode/ # Cache +.DS_Store __pycache__/ .DS_Store .tox/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2ab225c8..7a5dec4f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -80,7 +80,7 @@ run tests. And it is scattered commands to reproduce each step of the integratio ### With GitHub Action GitHub Action test in various environment for pydolphinscheduler, including different python version in -`3.6|3.7|3.8|3.9|3.10|3.11` and operating system `linux|macOS|windows`. It will trigger and run automatically when you +`3.6|3.7|3.8|3.9|3.10|3.11|3.12` and operating system `linux|macOS|windows`. It will trigger and run automatically when you submit pull requests to repository `apache/dolphinscheduler-sdk-python`. ### Automated Testing With tox @@ -214,7 +214,7 @@ make clean && make multiversion ## Unit Test pydolphinscheduler using [pytest][pytest] to test our codebase. GitHub Action will run our test when you create -pull request or commit to dev branch, with python version `3.6|3.7|3.8|3.9|3.10|3.11` and operating system `linux|macOS|windows`. +pull request or commit to dev branch, with python version `3.6|3.7|3.8|3.9|3.10|3.11|3.12` and operating system `linux|macOS|windows`. ### Unit Test Using tox diff --git a/setup.cfg b/setup.cfg index ad67231a..f8f28d7d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -49,6 +49,7 @@ classifiers = Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 Programming Language :: Python :: 3.11 + Programming Language :: Python :: 3.12 Programming Language :: Python :: Implementation :: CPython Programming Language :: Python :: Implementation :: PyPy Topic :: Software Development :: User Interfaces @@ -202,7 +203,7 @@ envlist = code-test integrate-test local-integrate-test - py{36,37,38,39,310,311} + py{36,37,38,39,310,311,312} [testenv] allowlist_externals = From 24b6a7a674877eafd79c99b0017a2e40ffd2a1e4 Mon Sep 17 00:00:00 2001 From: Jay Chung Date: Thu, 12 Oct 2023 19:22:58 +0800 Subject: [PATCH 2/4] add module compatible --- src/pydolphinscheduler/compatible/__init__.py | 1 + src/pydolphinscheduler/compatible/c_pkg_resources.py | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 src/pydolphinscheduler/compatible/__init__.py create mode 100644 src/pydolphinscheduler/compatible/c_pkg_resources.py diff --git a/src/pydolphinscheduler/compatible/__init__.py b/src/pydolphinscheduler/compatible/__init__.py new file mode 100644 index 00000000..869fd42c --- /dev/null +++ b/src/pydolphinscheduler/compatible/__init__.py @@ -0,0 +1 @@ +from pydolphinscheduler.compatible.c_pkg_resources import parse_requirements \ No newline at end of file diff --git a/src/pydolphinscheduler/compatible/c_pkg_resources.py b/src/pydolphinscheduler/compatible/c_pkg_resources.py new file mode 100644 index 00000000..681dc209 --- /dev/null +++ b/src/pydolphinscheduler/compatible/c_pkg_resources.py @@ -0,0 +1,5 @@ +try: + from pkg_resources import parse_requirements +except ImportError: + # Python 3.12 compatibility + from pip._vendor.pkg_resources import parse_requirements From 09ca3785396c0371c4f3101df68744c1bd860bf8 Mon Sep 17 00:00:00 2001 From: Jay Chung Date: Fri, 13 Oct 2023 16:16:39 +0800 Subject: [PATCH 3/4] fix pkg_resources is remove in py312 --- src/pydolphinscheduler/compatible/__init__.py | 1 - .../compatible/c_pkg_resources.py | 5 ----- src/pydolphinscheduler/utils/versions.py | 13 +++++-------- tests/utils/test_versions.py | 4 +++- 4 files changed, 8 insertions(+), 15 deletions(-) delete mode 100644 src/pydolphinscheduler/compatible/__init__.py delete mode 100644 src/pydolphinscheduler/compatible/c_pkg_resources.py diff --git a/src/pydolphinscheduler/compatible/__init__.py b/src/pydolphinscheduler/compatible/__init__.py deleted file mode 100644 index 869fd42c..00000000 --- a/src/pydolphinscheduler/compatible/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from pydolphinscheduler.compatible.c_pkg_resources import parse_requirements \ No newline at end of file diff --git a/src/pydolphinscheduler/compatible/c_pkg_resources.py b/src/pydolphinscheduler/compatible/c_pkg_resources.py deleted file mode 100644 index 681dc209..00000000 --- a/src/pydolphinscheduler/compatible/c_pkg_resources.py +++ /dev/null @@ -1,5 +0,0 @@ -try: - from pkg_resources import parse_requirements -except ImportError: - # Python 3.12 compatibility - from pip._vendor.pkg_resources import parse_requirements diff --git a/src/pydolphinscheduler/utils/versions.py b/src/pydolphinscheduler/utils/versions.py index 5fc93e51..4c1ea6f2 100644 --- a/src/pydolphinscheduler/utils/versions.py +++ b/src/pydolphinscheduler/utils/versions.py @@ -19,9 +19,8 @@ from pathlib import Path -from packaging import requirements +from packaging.requirements import Requirement as packaging_Requirement from packaging.version import InvalidVersion -from pkg_resources import parse_requirements from pydolphinscheduler.constants import Version @@ -34,13 +33,11 @@ def version_match(name: str, version: str) -> bool: """ path = Path(__file__).parent.parent.joinpath(Version.FILE_NAME) with path.open() as match: - content = match.read() - for reqs in parse_requirements(content): - if reqs.name == name: + for line in match.readlines(): + req = packaging_Requirement(line) + if req.name == name: try: - return requirements.Requirement(str(reqs)).specifier.contains( - version - ) + return req.specifier.contains(version) except InvalidVersion: return False raise ValueError("%s is not in %s" % (name, Version.FILE_NAME)) diff --git a/tests/utils/test_versions.py b/tests/utils/test_versions.py index b075e5e5..d01e5bf4 100644 --- a/tests/utils/test_versions.py +++ b/tests/utils/test_versions.py @@ -44,7 +44,9 @@ @mock.patch("pathlib.Path.open") def test_version_match(mock_open, content: str, name: str, version: str, expect: str): """Test function version_match.""" - mock_open.return_value.__enter__.return_value.read.return_value = content + mock_open.return_value.__enter__.return_value.readlines.return_value = [ + f"{content}\n" + ] assert version_match(name, version) == expect assert mock_open.call_count == 1 From c8b06ef4d94c8b83f90a98db4d30d80a227d8e2c Mon Sep 17 00:00:00 2001 From: Jay Chung Date: Fri, 13 Oct 2023 16:19:41 +0800 Subject: [PATCH 4/4] remove .DS_Store in gitignore --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 0c959f5b..41603809 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,6 @@ .vscode/ # Cache -.DS_Store __pycache__/ .DS_Store .tox/