From 37b9181ab01a014e9ae58bfa737c78b774fd453c Mon Sep 17 00:00:00 2001 From: Chris Griffith Date: Mon, 9 Dec 2024 21:20:24 -0600 Subject: [PATCH] Version 7.3.0 (#283) * Adding tests and Cython releases for Python 3.13 * Fixing #281 consistent error message about missing YAML parser (thanks to J vanBemmel) * Removing support for Python 3.8 as it is EOL --------- Co-authored-by: J vanBemmel --- .github/workflows/pythonpublish.yml | 19 ++++++------ .github/workflows/tests.yml | 47 +++++++++++++++-------------- .pre-commit-config.yaml | 6 ++-- CHANGES.rst | 7 +++++ box/__init__.py | 2 +- box/converters.py | 10 +++--- requirements-dev.txt | 3 +- requirements-test.txt | 4 +-- setup.py | 4 +-- 9 files changed, 57 insertions(+), 45 deletions(-) diff --git a/.github/workflows/pythonpublish.yml b/.github/workflows/pythonpublish.yml index 791b92a..c4478d8 100644 --- a/.github/workflows/pythonpublish.yml +++ b/.github/workflows/pythonpublish.yml @@ -18,7 +18,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.12' + python-version: '3.13' - name: Install Dependencies run: | @@ -38,8 +38,8 @@ jobs: deploy-cython: strategy: matrix: - os: [macos-11, windows-latest] - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] + os: [macos-latest, windows-latest] + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] runs-on: ${{ matrix.os }} steps: @@ -51,7 +51,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install setuptools wheel twine Cython==3.0.0 --upgrade + pip install setuptools wheel twine Cython>=3.0.11 --upgrade - name: Build and publish env: TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} @@ -64,10 +64,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Set up Python 3.12 + - name: Set up Python 3.13 uses: actions/setup-python@v5 with: - python-version: "3.12" + python-version: "3.13" - name: Build wheels run: | @@ -75,9 +75,10 @@ jobs: pip install cibuildwheel setuptools wheel python -m cibuildwheel --output-dir dist env: - CIBW_BUILD: cp38-manylinux_x86_64 cp39-manylinux_x86_64 cp310-manylinux_x86_64 cp311-manylinux_x86_64 cp312-manylinux_x86_64 - CIBW_BEFORE_BUILD: pip install Cython==3.0.0 - CIBW_BEFORE_TEST: pip install -r requirements.txt -r requirements-test.txt setuptools wheel twine + CIBW_BUILD: cp39-manylinux_x86_64 cp310-manylinux_x86_64 cp311-manylinux_x86_64 cp312-manylinux_x86_64 cp313-manylinux_x86_64 + CIBW_BEFORE_BUILD: pip install Cython>=3.0.11 setuptools wheel + CIBW_BEFORE_TEST: pip install -r requirements.txt -r requirements-test.txt setuptools wheel twine Cython>=3.0.11 + CIBW_BUILD_VERBOSITY: 1 CIBW_TEST_COMMAND: pytest {package}/test -vv - name: Publish diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 389b419..834bfc0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,8 +13,8 @@ jobs: package-checks: strategy: matrix: - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "pypy-3.8"] - os: [ubuntu-latest, macos-11, windows-latest] + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "pypy-3.10"] + os: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 @@ -22,16 +22,16 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: package-check-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements-test.txt') }} +# - uses: actions/cache@v3 +# with: +# path: ~/.cache/pip +# key: package-check-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements-test.txt') }} - name: Install dependencies run: | python -m pip install --upgrade pip pip install -r requirements.txt pip install -r requirements-test.txt - pip install coveralls flake8 flake8-print mypy setuptools wheel twine Cython==3.0.0 + pip install coveralls flake8 flake8-print mypy setuptools wheel twine Cython>=3.0.11 - name: Lint with flake8 run: | # stop the build if there are Python syntax errors, undefined names or print statements @@ -67,15 +67,15 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Set up Python 3.12 + - name: Set up Python 3.13 uses: actions/setup-python@v5 with: - python-version: "3.12" + python-version: "3.13" - - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: package-manylinux-check-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements-test.txt') }} +# - uses: actions/cache@v3 +# with: +# path: ~/.cache/pip +# key: package-manylinux-check-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements-test.txt') }} - name: Build wheels run: | @@ -83,9 +83,10 @@ jobs: pip install cibuildwheel python -m cibuildwheel --output-dir dist env: - CIBW_BUILD: cp38-manylinux_x86_64 cp39-manylinux_x86_64 cp310-manylinux_x86_64 cp311-manylinux_x86_64 cp312-manylinux_x86_64 - CIBW_BEFORE_BUILD: pip install Cython==3.0.0 - CIBW_BEFORE_TEST: pip install -r requirements.txt -r requirements-test.txt setuptools wheel twine + CIBW_BUILD: cp39-manylinux_x86_64 cp310-manylinux_x86_64 cp311-manylinux_x86_64 cp312-manylinux_x86_64 cp313-manylinux_x86_64 + CIBW_BEFORE_BUILD: pip install Cython>=3.0.11 setuptools wheel + CIBW_BEFORE_TEST: pip install -r requirements.txt -r requirements-test.txt setuptools wheel twine Cython>=3.0.11 + CIBW_BUILD_VERBOSITY: 1 CIBW_TEST_COMMAND: pytest {package}/test -vv - name: Upload wheel artifact @@ -97,8 +98,8 @@ jobs: test: strategy: matrix: - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] - os: [ubuntu-latest, macos-11, windows-latest] + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] + os: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 @@ -106,16 +107,16 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: test-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements-test.txt') }} +# - uses: actions/cache@v3 +# with: +# path: ~/.cache/pip +# key: test-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements-test.txt') }} - name: Install dependencies run: | python -m pip install --upgrade pip pip install -r requirements.txt pip install -r requirements-test.txt - pip install setuptools wheel Cython==3.0.0 + pip install setuptools wheel Cython>=3.0.11 python setup.py build_ext --inplace - name: Test with pytest env: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b91d368..cee0904 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: # Identify invalid files - id: check-ast @@ -29,7 +29,7 @@ repos: exclude: ^test/data/.+ - repo: https://github.com/ambv/black - rev: 24.4.2 + rev: 24.10.0 hooks: - id: black args: [--config=.black.toml] @@ -51,7 +51,7 @@ repos: always_run: true - repo: https://github.com/pre-commit/mirrors-mypy - rev: 'v1.10.0' + rev: 'v1.13.0' hooks: - id: mypy types: [python] diff --git a/CHANGES.rst b/CHANGES.rst index f2db4c8..e6b19a8 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,6 +1,13 @@ Changelog ========= +Version 7.3.0 +------------- + +* Adding tests and Cython releases for Python 3.13 +* Fixing #281 consistent error message about missing YAML parser (thanks to J vanBemmel) +* Removing support for Python 3.8 as it is EOL + Version 7.2.0 ------------- diff --git a/box/__init__.py b/box/__init__.py index adc6199..0f805f9 100644 --- a/box/__init__.py +++ b/box/__init__.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- __author__ = "Chris Griffith" -__version__ = "7.2.0" +__version__ = "7.3.0" from box.box import Box from box.box_list import BoxList diff --git a/box/converters.py b/box/converters.py index 3bb003b..a464046 100644 --- a/box/converters.py +++ b/box/converters.py @@ -29,6 +29,8 @@ except ImportError: pyyaml_available = False +MISSING_PARSER_ERROR = "No YAML Parser available, please install ruamel.yaml>=0.17 or PyYAML" + toml_read_library: Optional[Any] = None toml_write_library: Optional[Any] = None toml_decode_error: Optional[Callable] = None @@ -196,7 +198,7 @@ def _to_yaml( elif pyyaml_available: return yaml.dump(obj, stream=f, default_flow_style=default_flow_style, **yaml_kwargs) else: - raise BoxError("No YAML Parser available, please install ruamel.yaml>0.17 or PyYAML") + raise BoxError(MISSING_PARSER_ERROR) else: if ruamel_available: @@ -210,7 +212,7 @@ def _to_yaml( elif pyyaml_available: return yaml.dump(obj, default_flow_style=default_flow_style, **yaml_kwargs) else: - raise BoxError("No YAML Parser available, please install ruamel.yaml>0.17 or PyYAML") + raise BoxError(MISSING_PARSER_ERROR) def _from_yaml( @@ -237,7 +239,7 @@ def _from_yaml( kwargs["Loader"] = yaml.SafeLoader data = yaml.load(f, **kwargs) else: - raise BoxError("No YAML Parser available, please install ruamel.yaml>0.15 or PyYAML") + raise BoxError(MISSING_PARSER_ERROR) elif yaml_string: if ruamel_available: yaml_loader = YAML(typ=ruamel_typ) @@ -249,7 +251,7 @@ def _from_yaml( kwargs["Loader"] = yaml.SafeLoader data = yaml.load(yaml_string, **kwargs) else: - raise BoxError("No YAML Parser available, please install ruamel.yaml>0.17 or PyYAML") + raise BoxError(MISSING_PARSER_ERROR) else: raise BoxError("from_yaml requires a string or filename") return data diff --git a/requirements-dev.txt b/requirements-dev.txt index e41d73f..617f8b9 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,5 +1,6 @@ # Files needed for pre-commit hooks black>=23.1.0 -Cython==3.0.0 +Cython>=3.0.11 mypy>=1.0.1 pre-commit>=2.21.0 +setuptools>=75.6.0 diff --git a/requirements-test.txt b/requirements-test.txt index 1296ffa..0952d6f 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -1,7 +1,7 @@ -coverage>=5.0.4 +coverage>=7.6.9 msgpack>=1.0 pytest>=7.1.3 -pytest-cov>=2.8.1 +pytest-cov<6.0.0 ruamel.yaml>=0.17 tomli>=1.2.3; python_version < '3.11' tomli-w>=1.0.0 diff --git a/setup.py b/setup.py index 3781c42..8abda61 100644 --- a/setup.py +++ b/setup.py @@ -45,17 +45,17 @@ py_modules=["box"], packages=["box"], ext_modules=extra, - python_requires=">=3.8", + python_requires=">=3.9", include_package_data=True, platforms="any", classifiers=[ "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Programming Language :: Python :: Implementation :: CPython", "Development Status :: 5 - Production/Stable", "Natural Language :: English",