Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions .bumpversion.cfg

This file was deleted.

20 changes: 8 additions & 12 deletions .github/workflows/python-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,21 @@ permissions: {}
jobs:
release:
runs-on: ubuntu-latest
environment: pypi
permissions:
contents: write # attach the SBOM to the GitHub release
id-token: write # PyPI trusted publishing (OIDC)
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: Set up Python 3.13
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
- uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
with:
python-version: "3.13"

- name: Install build requirements
run: python -m pip install uv
enable-cache: false

- name: Build package
run: uv build
Expand All @@ -33,7 +32,7 @@ jobs:
id: version
run: |
set -euo pipefail
version=$(python - <<'PY'
version=$(uv run --no-project python - <<'PY'
import glob, zipfile
whl = glob.glob("dist/*.whl")[0]
with zipfile.ZipFile(whl) as z:
Expand Down Expand Up @@ -76,31 +75,28 @@ jobs:

- name: Publish package
uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2
with:
user: __token__
password: ${{ secrets.pypi_password }}

- name: Attach SBOM to release
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ github.event.release.tag_name }}
run: gh release upload "${TAG}" commercetools.spdx.json commercetools.cdx.json --clobber

- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: sbom-cyclonedx
path: commercetools.cdx.json
retention-days: 7

# Separate job so the DT key is never present while repo code runs (the build
# above executes setup.py).
# above executes the build backend).
dependencytrack:
needs: release
if: github.event_name == 'release' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
permissions: {}
steps:
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: sbom-cyclonedx

Expand Down
77 changes: 44 additions & 33 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
@@ -1,56 +1,67 @@
name: Python Tests

on:
# This should run the workflow for all non-forked pushes
push:
branches: ["main"]
pull_request:
branches:
# This should run the workflow for forked PRs
- '**:**'

permissions:
contents: read

jobs:

format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: Set up Python 3.13
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: "3.13"
- uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
with:
python-version: "3.14"

- name: Install dependencies
run: pip install tox
- name: Check formatting
run: uv run --frozen ruff format --check src tests

- name: Validate formatting
run: tox -e format
- name: Lint
run: uv run --frozen ruff check src tests

test:
runs-on: ubuntu-latest
strategy:
max-parallel: 4
fail-fast: false
matrix:
python-version: ["3.11", "3.12", "3.13", "3.14"]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox tox-gh-actions

- name: Test with tox
run: tox
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: uv sync --frozen --group test

- name: Run tests
run: uv run --frozen coverage run --source commercetools --parallel -m pytest

- name: Coverage report
run: |
uv run --frozen coverage combine
uv run --frozen coverage report

docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
with:
python-version: "3.13"

- name: Build docs
run: uv run --frozen --group docs sphinx-build -q -b html docs docs/_build/html
14 changes: 11 additions & 3 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@ build:
os: ubuntu-24.04
tools:
python: "3.13"
jobs:
pre_create_environment:
- asdf plugin add uv
- asdf install uv latest
- asdf global uv latest
create_environment:
- uv venv "${READTHEDOCS_VIRTUALENV_PATH}"
install:
- UV_PROJECT_ENVIRONMENT="${READTHEDOCS_VIRTUALENV_PATH}" uv sync --frozen --group docs

python:
install:
- requirements: requirements_dev.txt
sphinx:
configuration: docs/conf.py
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Unreleased
----------
- *BREAKING*: requires Python 3.11 or newer; tested on 3.11–3.14.
- Packaging moved to `pyproject.toml` (hatchling) and uv; the `test` and `docs`
extras are removed (now dependency groups).
- `commercetools.__version__` reports the actual package version again.

26.10.12
--------
Expand Down
16 changes: 0 additions & 16 deletions MANIFEST.in

This file was deleted.

30 changes: 12 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,36 @@


install:
pip install -e .[test]
uv sync --all-groups

generate:
java -jar ../rmf-codegen/rmf-codegen.jar generate ../commercetools-api-reference/api-specs/api/api.raml -o src/commercetools/platform/ -t PYTHON_CLIENT
java -jar ../rmf-codegen/rmf-codegen.jar generate ../commercetools-api-reference/api-specs/importapi/api.raml -o src/commercetools/importapi/ -t PYTHON_CLIENT
java -jar ../rmf-codegen/rmf-codegen.jar generate ../commercetools-api-reference/api-specs/frontend-api/api.raml -o src/commercetools/frontend/ -t PYTHON_CLIENT
java -jar ../rmf-codegen/rmf-codegen.jar generate ../commercetools-api-reference/api-specs/checkout/api.raml -o src/commercetools/checkout/ -t PYTHON_CLIENT
find src/ -name "gen.properties" -delete
ruff check --fix --select I src/commercetools/
ruff format src/commercetools/
uv run ruff check --fix --select I src/commercetools/
uv run ruff format src/commercetools/

test:
pytest tests/
uv run pytest tests/

mypy:
mypy --config-file=mypy.ini src/commercetools
uv run mypy --config-file=mypy.ini src/commercetools

coverage:
pytest --cov=commercetools
uv run pytest --cov=commercetools

runserver:
python -mcommercetools.testing.server
uv run python -mcommercetools.testing.server

format:
ruff check --fix src tests
ruff format src tests
uv run ruff check --fix src tests
uv run ruff format src tests

lint:
ruff format --check src tests
ruff check src tests

release:
pip install twine wheel
rm -rf build/* dist/*
python setup.py sdist bdist_wheel
twine upload dist/*
uv run ruff format --check src tests
uv run ruff check src tests

docs:
make -C docs html
uv run --group docs make -C docs html
19 changes: 9 additions & 10 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
.. start-no-pypi
Python SDK for Commercetools
============================

.. image:: https://github.com/labd/commercetools-python-sdk/workflows/Python%20Tests/badge.svg
:target: https://github.com/labd/commercetools-python-sdk/actions
.. image:: https://img.shields.io/pypi/v/commercetools
:target: https://pypi.org/project/commercetools/
:alt: PyPI

.. image:: https://github.com/labd/commercetools-python-sdk/actions/workflows/python-test.yml/badge.svg
:target: https://github.com/labd/commercetools-python-sdk/actions/workflows/python-test.yml
:alt: Python Tests

.. image:: https://img.shields.io/pypi/v/commercetools.svg
:target: https://pypi.python.org/pypi/commercetools/
.. image:: https://readthedocs.org/projects/commercetools-python-sdk/badge/?version=latest
:target: https://commercetools-python-sdk.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status
.. end-no-pypi


Python SDK for Commercetools
============================

This is an unofficial Python SDK for the Commercetools platform. It only
supports Python 3.11+ and uses type annotation for an improved development
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,4 +200,4 @@
# -- Options for intersphinx extension ---------------------------------------

# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {"https://docs.python.org/": None}
intersphinx_mapping = {"python": ("https://docs.python.org/3", None)}
Loading
Loading