Skip to content

Commit 41076ed

Browse files
Derive package version from git tags via setuptools-scm (#131)
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.
1 parent 0a811de commit 41076ed

6 files changed

Lines changed: 18 additions & 6 deletions

File tree

.github/workflows/main.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ jobs:
2020
runs-on: ubuntu-latest
2121
steps:
2222
- uses: actions/checkout@v6
23+
with:
24+
fetch-depth: 0
2325
- name: Set up Python
2426
uses: actions/setup-python@v6
2527
with:
@@ -44,6 +46,8 @@ jobs:
4446
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
4547
steps:
4648
- uses: actions/checkout@v6
49+
with:
50+
fetch-depth: 0
4751
- name: Set up Python
4852
uses: actions/setup-python@v6
4953
with:
@@ -62,6 +66,8 @@ jobs:
6266
runs-on: ubuntu-latest
6367
steps:
6468
- uses: actions/checkout@v6
69+
with:
70+
fetch-depth: 0
6571
- name: Set up Python
6672
uses: actions/setup-python@v6
6773
with:

.github/workflows/publish.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ jobs:
1515
environment: pypi
1616
steps:
1717
- uses: actions/checkout@v6
18+
with:
19+
fetch-depth: 0
1820

1921
- name: Set up Python
2022
uses: actions/setup-python@v6

customerio/__version__.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

customerio/client_base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
import math
66
import socket
77
from datetime import datetime, timezone
8+
from importlib.metadata import version
89

910
from requests import Session
1011
from requests.adapters import DEFAULT_POOLBLOCK, HTTPAdapter
1112
from urllib3.connection import HTTPConnection
1213
from urllib3.util.retry import Retry
1314

14-
from .__version__ import __version__ as ClientVersion
15+
ClientVersion = version("customerio")
1516

1617
TCP_KEEPALIVE_IDLE_TIMEOUT = 300
1718
TCP_KEEPALIVE_INTERVAL = 60

pyproject.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
[build-system]
2-
requires = ["setuptools>=77", "wheel"]
2+
requires = ["setuptools>=77", "setuptools-scm>=8", "wheel"]
33
build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "customerio"
77
dynamic = ["version"]
8+
# Version is derived from git tags via setuptools-scm (e.g. tag v3.0.0 → version 3.0.0)
89
description = "Customer.io Python bindings."
910
readme = "README.md"
1011
requires-python = ">=3.10"
@@ -44,8 +45,9 @@ Homepage = "https://github.com/customerio/customerio-python"
4445
Releases = "https://github.com/customerio/customerio-python/releases"
4546
Issues = "https://github.com/customerio/customerio-python/issues"
4647

47-
[tool.setuptools.dynamic]
48-
version = { attr = "customerio.__version__.__version__" }
48+
[tool.setuptools_scm]
49+
version_scheme = "guess-next-dev"
50+
local_scheme = "no-local-version"
4951

5052
[tool.setuptools.packages.find]
5153
include = ["customerio*"]

tests/test_api.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import json
33
import unittest
44
from functools import partial
5+
from importlib.metadata import version
56

67
import urllib3
78

@@ -15,9 +16,10 @@
1516
SendPushRequest,
1617
SendSMSRequest,
1718
)
18-
from customerio.__version__ import __version__ as ClientVersion
1919
from tests.server import HTTPSTestCase
2020

21+
ClientVersion = version("customerio")
22+
2123
# test uses a self signed certificate so disable the warning messages
2224
urllib3.disable_warnings()
2325

0 commit comments

Comments
 (0)