diff --git a/.github/workflows/python-release.yml b/.github/workflows/python-release.yml index fca94cb0..5a8b3a9c 100644 --- a/.github/workflows/python-release.yml +++ b/.github/workflows/python-release.yml @@ -8,17 +8,17 @@ jobs: release: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Set up Python 3.10 - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 + - name: Set up Python 3.12 + uses: actions/setup-python@v5 with: - python-version: "3.10" + python-version: "3.12" - name: Install build requirements - run: python -m pip install wheel + run: python -m pip install setuptools wheel - name: Build package run: python setup.py sdist bdist_wheel - name: Publish package - uses: pypa/gh-action-pypi-publish@master + uses: pypa/gh-action-pypi-publish@release/v1 with: user: __token__ password: ${{ secrets.pypi_password }} diff --git a/.github/workflows/python-test.yml b/.github/workflows/python-test.yml index 802028c4..b781e118 100644 --- a/.github/workflows/python-test.yml +++ b/.github/workflows/python-test.yml @@ -14,12 +14,12 @@ jobs: format: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - - name: Set up Python 3.10 - uses: actions/setup-python@v4 + - name: Set up Python 3.12 + uses: actions/setup-python@v5 with: - python-version: "3.10" + python-version: "3.12" - name: Install dependencies run: pip install tox @@ -32,12 +32,12 @@ jobs: strategy: max-parallel: 4 matrix: - python-version: ["3.8", "3.9", "3.10", "3.11"] + python-version: ["3.12"] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} @@ -52,26 +52,27 @@ jobs: - name: Prepare artifacts run: mkdir .coverage-data && mv .coverage.* .coverage-data/ - - uses: actions/upload-artifact@master + - uses: actions/upload-artifact@v4 with: name: coverage-data-${{ matrix.python-version }} path: .coverage-data/ + include-hidden-files: true coverage: runs-on: ubuntu-latest needs: [test] steps: - - uses: actions/checkout@v3 - - uses: actions/download-artifact@master + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 with: pattern: coverage-data-* path: . merge-multiple: true - - name: Set up Python 3.10 - uses: actions/setup-python@v4 + - name: Set up Python 3.12 + uses: actions/setup-python@v5 with: - python-version: "3.10" + python-version: "3.12" - name: Install dependencies run: | diff --git a/CHANGES.md b/CHANGES.md index 2d051192..0e856d6b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,14 @@ +26.9.28 +------- +- Add Python 3.12 support and drop Python 3.6-3.11 (`python_requires >= 3.12`). +- Import `RAISE` from `marshmallow` instead of `marshmallow.utils`. +- Require `marshmallow>=3.13`: deserialization fails on 3.10-3.12. +- Cap `marshmallow<4`: 4.x removes APIs used by `helpers.Discriminator`. +- Install setuptools explicitly for release builds (Python 3.12 ships without it). +- Update test tooling for Python 3.12 (pytest, pytest-cov, flake8, mypy). +- Pin `pypi-publish` and artifact actions instead of tracking `@master`. +- Fix timing flake in `test_auto_refresh`. + 23.6.29 -------- - Regenerate code with latest RAML specifications, bringing the SDK up to date diff --git a/Makefile b/Makefile index dc8f6875..b2777f47 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,7 @@ format: black src/ tests/ release: - pip install twine wheel + pip install setuptools twine wheel rm -rf build/* dist/* python setup.py sdist bdist_wheel twine upload dist/* diff --git a/README.rst b/README.rst index 073ef3b3..323e2b4e 100644 --- a/README.rst +++ b/README.rst @@ -18,7 +18,7 @@ Python SDK for Commercetools ============================ This is an unofficial Python SDK for the Commercetools platform. It only -supports Python 3.6+ and uses type annotation for an improved development +supports Python 3.12+ and uses type annotation for an improved development experience. The API is generated using the commercetools api RAML file and uses diff --git a/docs/index.rst b/docs/index.rst index cd0bedad..daa03d95 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -2,7 +2,7 @@ Commercetools Python SDK ======================== This is an unofficial Python SDK for the Commercetools platform. It only -supports Python 3.6+ and uses type annotation for an improved development +supports Python 3.12+ and uses type annotation for an improved development experience. The API is mostly generated using the commercetools api RAML file and uses the diff --git a/mypy.ini b/mypy.ini index 88ed9fd7..77d5b5b7 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1,6 +1,6 @@ [mypy] ignore_missing_imports = True -python_version = 3.6 +python_version = 3.12 warn_unused_configs = True mypy_path = src check_untyped_defs = True diff --git a/setup.py b/setup.py index f1a8a499..c616b46a 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,9 @@ "pytz", "requests-oauthlib>=1.0.0", "requests_mock>=1.8.0", - "marshmallow>=3.10.0", + # marshmallow 4 drops `default=`, `Schema(context=)` and `Field.fail()`, all + # used by helpers.Discriminator; hold at 3.x until that is ported. + "marshmallow>=3.13.0,<4", "marshmallow-enum>=1.5.1", "WebOb>=1.8.0", "Werkzeug>=0.15.2", @@ -25,15 +27,14 @@ "mock==4.0.3", "pretend==1.0.9", "coverage[toml]>=6.2", - "pytest-cov==3.0.0", - "pytest==7.0.1", + "pytest-cov==7.1.0", + "pytest==9.1.1", # Linting "isort==5.10.1", - "flake8==4.0.1", - "flake8-blind-except==0.2.0", - "flake8-debugger==4.0.0", - "flake8-imports==0.1.1", - "mypy==0.931", + "flake8==7.4.1", + "flake8-blind-except==0.2.1", + "flake8-debugger==4.1.2", + "mypy==2.3.1", ] @@ -44,12 +45,13 @@ setup( name="commercetools", - version="2023.6.29", + version="2026.9.28", description="SDK for Commercetools", long_description=long_description, author="Lab Digital B.V.", author_email="opensource@labdigital.nl", url="https://github.com/labd/commercetools-python-sdk", + python_requires=">=3.12", install_requires=install_requires, tests_require=tests_require, extras_require={ @@ -65,10 +67,7 @@ "Development Status :: 5 - Production/Stable", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.12", "Programming Language :: Python :: Implementation :: CPython", ], zip_safe=False, diff --git a/src/commercetools/helpers.py b/src/commercetools/helpers.py index 6655fb3c..fdd08f58 100644 --- a/src/commercetools/helpers.py +++ b/src/commercetools/helpers.py @@ -2,14 +2,14 @@ import inspect import typing -from marshmallow import Schema, class_registry, fields, missing, post_dump +from marshmallow import RAISE, Schema, class_registry, fields, missing, post_dump from marshmallow.exceptions import ( RegistryError, StringNotCollectionError, ValidationError, ) from marshmallow.fields import Field, Nested -from marshmallow.utils import RAISE, is_collection +from marshmallow.utils import is_collection from marshmallow.utils import missing as missing_ from commercetools.exceptions import CommercetoolsError diff --git a/src/commercetools/version.py b/src/commercetools/version.py index 70f7a685..7522a125 100644 --- a/src/commercetools/version.py +++ b/src/commercetools/version.py @@ -1 +1 @@ -__version__ = "2023.6.29" +__version__ = "2026.9.28" diff --git a/tests/platform/test_client.py b/tests/platform/test_client.py index a0541d95..272bf593 100644 --- a/tests/platform/test_client.py +++ b/tests/platform/test_client.py @@ -39,7 +39,8 @@ def test_auto_refresh(commercetools_api): token_url="https://auth.europe-west1.gcp.commercetools.com/oauth/token", ) client.products.query() - time.sleep(1) + # oauthlib stores an integer expires_at, so wait past the 1s expiry with margin + time.sleep(2) client.products.query() client.products.query() diff --git a/tox.ini b/tox.ini index 65240019..d2b10c75 100644 --- a/tox.ini +++ b/tox.ini @@ -1,20 +1,16 @@ [tox] -envlist = py36,py37,py38,py39,py310 +envlist = py312 [gh-actions] python = - 3.6: py36 - 3.7: py37 - 3.8: py38 - 3.9: py39 - 3.10: py310 + 3.12: py312 [testenv] commands = coverage run --source commercetools --parallel -m pytest {posargs} extras = test [testenv:coverage-report] -basepython = python3.10 +basepython = python3.12 deps = coverage[toml] skip_install = true commands = @@ -23,7 +19,7 @@ commands = coverage report [testenv:format] -basepython = python3.10 +basepython = python3.12 deps = black==22.6.0 isort[toml]==5.10.1