From dba5e597140e0f71a48e2a369ddfbf4fc8885f1d Mon Sep 17 00:00:00 2001 From: Stephen Young Date: Fri, 22 May 2026 16:45:23 -0400 Subject: [PATCH 1/2] Derive package version from git tags via setuptools-scm Removes the manually maintained __version__.py file. Version is now read from git tags at build time by setuptools-scm, so cutting a GitHub release is the only step needed to publish a new version. --- .github/workflows/publish.yml | 2 ++ customerio/__version__.py | 1 - customerio/client_base.py | 3 ++- pyproject.toml | 8 +++++--- tests/test_api.py | 4 +++- 5 files changed, 12 insertions(+), 6 deletions(-) delete mode 100644 customerio/__version__.py diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index b0eef53..787f987 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -15,6 +15,8 @@ jobs: environment: pypi steps: - uses: actions/checkout@v6 + with: + fetch-depth: 0 - name: Set up Python uses: actions/setup-python@v6 diff --git a/customerio/__version__.py b/customerio/__version__.py deleted file mode 100644 index 528787c..0000000 --- a/customerio/__version__.py +++ /dev/null @@ -1 +0,0 @@ -__version__ = "3.0.0" diff --git a/customerio/client_base.py b/customerio/client_base.py index 74c9d7d..4e63dd7 100644 --- a/customerio/client_base.py +++ b/customerio/client_base.py @@ -5,13 +5,14 @@ import math import socket from datetime import datetime, timezone +from importlib.metadata import version from requests import Session from requests.adapters import DEFAULT_POOLBLOCK, HTTPAdapter from urllib3.connection import HTTPConnection from urllib3.util.retry import Retry -from .__version__ import __version__ as ClientVersion +ClientVersion = version("customerio") TCP_KEEPALIVE_IDLE_TIMEOUT = 300 TCP_KEEPALIVE_INTERVAL = 60 diff --git a/pyproject.toml b/pyproject.toml index bcd5c7f..6f3995c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,11 @@ [build-system] -requires = ["setuptools>=77", "wheel"] +requires = ["setuptools>=77", "setuptools-scm>=8", "wheel"] build-backend = "setuptools.build_meta" [project] name = "customerio" dynamic = ["version"] +# Version is derived from git tags via setuptools-scm (e.g. tag v3.0.0 → version 3.0.0) description = "Customer.io Python bindings." readme = "README.md" requires-python = ">=3.10" @@ -44,8 +45,9 @@ Homepage = "https://github.com/customerio/customerio-python" Changelog = "https://github.com/customerio/customerio-python/blob/main/CHANGELOG.md" Issues = "https://github.com/customerio/customerio-python/issues" -[tool.setuptools.dynamic] -version = { attr = "customerio.__version__.__version__" } +[tool.setuptools_scm] +version_scheme = "guess-next-dev" +local_scheme = "no-local-version" [tool.setuptools.packages.find] include = ["customerio*"] diff --git a/tests/test_api.py b/tests/test_api.py index 2b71c63..d994f25 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -2,6 +2,7 @@ import json import unittest from functools import partial +from importlib.metadata import version import urllib3 @@ -15,9 +16,10 @@ SendPushRequest, SendSMSRequest, ) -from customerio.__version__ import __version__ as ClientVersion from tests.server import HTTPSTestCase +ClientVersion = version("customerio") + # test uses a self signed certificate so disable the warning messages urllib3.disable_warnings() From 6ab75d1525728134afad6666cfabaf238ec9d1c0 Mon Sep 17 00:00:00 2001 From: Stephen Young Date: Mon, 25 May 2026 21:46:38 -0400 Subject: [PATCH 2/2] fetch depth everywhere --- .github/workflows/main.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 91adeb6..abb6ebd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -20,6 +20,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 + with: + fetch-depth: 0 - name: Set up Python uses: actions/setup-python@v6 with: @@ -44,6 +46,8 @@ jobs: python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"] steps: - uses: actions/checkout@v6 + with: + fetch-depth: 0 - name: Set up Python uses: actions/setup-python@v6 with: @@ -62,6 +66,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 + with: + fetch-depth: 0 - name: Set up Python uses: actions/setup-python@v6 with: