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: 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 f5f41e5..0000000 --- a/customerio/__version__.py +++ /dev/null @@ -1 +0,0 @@ -__version__ = "3.1.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 d7ee57c..40cb20a 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" Releases = "https://github.com/customerio/customerio-python/releases" 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()