Skip to content

Commit 50dbd1e

Browse files
committed
Modernize Python CI and packaging
1 parent b07e0d1 commit 50dbd1e

16 files changed

Lines changed: 992 additions & 738 deletions

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
directory: "/"
5+
schedule:
6+
interval: weekly
7+
8+
- package-ecosystem: pip
9+
directory: "/"
10+
schedule:
11+
interval: weekly

.github/workflows/main.yml

Lines changed: 64 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,76 @@
1-
name: build
1+
name: CI
22

33
on:
44
push:
55
pull_request:
66
workflow_dispatch:
77

8+
permissions:
9+
contents: read
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
14+
815
jobs:
9-
build:
16+
lint:
17+
name: Lint and format
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v6
21+
- name: Set up Python
22+
uses: actions/setup-python@v6
23+
with:
24+
python-version: "3.14"
25+
cache: pip
26+
cache-dependency-path: pyproject.toml
27+
- name: Install dependencies
28+
run: |
29+
python -m pip install --upgrade pip
30+
python -m pip install -e ".[dev]"
31+
- name: Run ruff
32+
run: |
33+
python -m ruff check .
34+
python -m ruff format --check .
35+
36+
test:
37+
name: Test Python ${{ matrix.python-version }}
1038
runs-on: ubuntu-latest
1139
strategy:
1240
fail-fast: false
1341
matrix:
14-
python: [ '3.9', '3.10', '3.11', '3.12', '3.13' ]
42+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
43+
steps:
44+
- uses: actions/checkout@v6
45+
- name: Set up Python
46+
uses: actions/setup-python@v6
47+
with:
48+
python-version: ${{ matrix.python-version }}
49+
cache: pip
50+
cache-dependency-path: pyproject.toml
51+
- name: Install package
52+
run: |
53+
python -m pip install --upgrade pip
54+
python -m pip install -e .
55+
- name: Run tests
56+
run: make test
57+
58+
package:
59+
name: Build distribution
60+
runs-on: ubuntu-latest
1561
steps:
16-
- uses: actions/checkout@v4
17-
- name: Set up Python
18-
uses: actions/setup-python@v5.6.0
19-
with:
20-
python-version: ${{ matrix.python }}
21-
- name: install dependencies for the minor version
22-
run: |
23-
python -m venv venv
24-
. venv/bin/activate
25-
pip install -r requirements.txt
26-
- name: run tests
27-
run: |
28-
. venv/bin/activate
29-
make test
30-
deactivate
31-
- name: reinstall to the latest version
32-
run: |
33-
python -m venv venv
34-
. venv/bin/activate
35-
pip install --upgrade requests
36-
- name: run tests again
37-
run: |
38-
. venv/bin/activate
39-
make test
62+
- uses: actions/checkout@v6
63+
- name: Set up Python
64+
uses: actions/setup-python@v6
65+
with:
66+
python-version: "3.14"
67+
cache: pip
68+
cache-dependency-path: pyproject.toml
69+
- name: Install build tools
70+
run: |
71+
python -m pip install --upgrade pip
72+
python -m pip install -e ".[dev]"
73+
- name: Build and verify package
74+
run: |
75+
python -m build
76+
python -m twine check dist/*

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
*.pyc
22
*.pyo
3+
.venv/
4+
.coverage
5+
.ruff_cache/
6+
.pytest_cache/
37
tests/server.pem
48
dist
59
customerio.egg-info
610
.DS_Store
711
MANIFEST
812
build/
9-
setup.cfg
13+
setup.cfg

Makefile

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,37 @@
11
PYTHON ?= python3
2+
OPENSSL ?= openssl
3+
SERVER_CERT := tests/server.pem
24

3-
all:
4-
$(PYTHON) setup.py sdist
5+
all: build
56
$(PYTHON) -m doctest ./customerio/__init__.py
67

78
install:
8-
$(PYTHON) setup.py install
9+
$(PYTHON) -m pip install .
910

1011
clean:
11-
$(PYTHON) setup.py clean
12-
rm -rf MANIFEST build dist
12+
rm -rf MANIFEST build dist customerio.egg-info .ruff_cache
1313

1414
dev: clean all
1515
if ! pip uninstall customerio; then echo "customerio not installed, installing it for the first time" ; fi
1616
pip install dist/*
1717
$(PYTHON) -i -c "from customerio import *"
1818

1919
upload:
20-
$(PYTHON) setup.py register
21-
echo "*** Now upload the binary to PyPi *** (one second)" && sleep 3 && open dist & open "http://pypi.python.org/pypi?%3Aaction=pkg_edit&name=customerio" # python setup.py upload
20+
$(PYTHON) -m twine upload dist/*
2221

23-
test:
24-
openssl req -new -newkey rsa:2048 -days 10 -nodes -x509 -subj "/C=CA/ST=Ontario/L=Toronto/O=Test/CN=127.0.0.1" -keyout ./tests/server.pem -out ./tests/server.pem
22+
build:
23+
$(PYTHON) -m build
24+
25+
lint:
26+
$(PYTHON) -m ruff check .
27+
$(PYTHON) -m ruff format --check .
28+
29+
format:
30+
$(PYTHON) -m ruff check --fix .
31+
$(PYTHON) -m ruff format .
32+
33+
test: $(SERVER_CERT)
2534
$(PYTHON) -m unittest discover -v
35+
36+
$(SERVER_CERT):
37+
$(OPENSSL) req -new -newkey rsa:2048 -days 10 -nodes -x509 -subj "/C=CA/ST=Ontario/L=Toronto/O=Test/CN=127.0.0.1" -keyout $(SERVER_CERT) -out $(SERVER_CERT)

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/customerio)
1212
![PyPI - Downloads](https://img.shields.io/pypi/dm/customerio)
1313

14-
# Customer.io Python
14+
# Customer.io Python
1515

16-
This module has been tested with Python 3.6, 3.7, 3.8 and 3.9. If you're new to Customer.io, we recommend that you integrate with our [Data Pipelines Python library](https://github.com/customerio/cdp-analytics-python) instead.
16+
This module is tested with Python 3.10 through 3.14. If you're new to Customer.io, we recommend that you integrate with our [Data Pipelines Python library](https://github.com/customerio/cdp-analytics-python) instead.
1717

1818
## Installing
1919

customerio/__init__.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
1-
import warnings
2-
1+
from customerio.api import (
2+
APIClient,
3+
SendEmailRequest,
4+
SendInAppRequest,
5+
SendInboxMessageRequest,
6+
SendPushRequest,
7+
SendSMSRequest,
8+
)
39
from customerio.client_base import CustomerIOException
4-
from customerio.track import CustomerIO
5-
from customerio.api import APIClient, SendEmailRequest, SendPushRequest, SendSMSRequest, SendInboxMessageRequest, SendInAppRequest
610
from customerio.regions import Regions
11+
from customerio.track import CustomerIO
12+
13+
__all__ = [
14+
"APIClient",
15+
"CustomerIO",
16+
"CustomerIOException",
17+
"Regions",
18+
"SendEmailRequest",
19+
"SendInAppRequest",
20+
"SendInboxMessageRequest",
21+
"SendPushRequest",
22+
"SendSMSRequest",
23+
]

customerio/__version__.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1 @@
1-
VERSION = (2, 4, 0, 'final', 0)
2-
3-
def get_version():
4-
version = '%s.%s' % (VERSION[0], VERSION[1])
5-
if VERSION[2]:
6-
version = '%s.%s' % (version, VERSION[2])
7-
if VERSION[3:] == ('alpha', 0):
8-
version = '%s-pre-alpha' % version
9-
else:
10-
if VERSION[3] != 'final':
11-
version = '%s-%s-%s' % (version, VERSION[3], VERSION[4])
12-
return version
13-
14-
__version__=get_version()
1+
__version__ = "2.4.0"

0 commit comments

Comments
 (0)