Skip to content

Commit 19a1bbe

Browse files
authored
Deprecate EOL python versions and migrate to pyproject.toml (#135)
* Deprecate EOL python versions and migrate to pyproject.toml * temp file removal * bump dependent actions versions * fix pypy version * Add python 3.13 and pypy311 - no breaking changes' * undo demo app change * test file update * Adding read-only permission to github action * remove test pkg exclusion * mixpanel should be the only top level pkg * Fix changelist version * cleanup-removing commented code line
1 parent b53d315 commit 19a1bbe

File tree

12 files changed

+104
-108
lines changed

12 files changed

+104
-108
lines changed

.github/workflows/test.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,26 @@ name: Tests
22

33
on: [push]
44

5+
permissions:
6+
contents: read
7+
58
jobs:
69
test:
7-
runs-on: ubuntu-20.04
10+
runs-on: ubuntu-24.04
811
strategy:
912
matrix:
10-
python-version: ['3.5', '3.6', '3.7', '3.8', '3.9', '3.10', '3.11', '3.12', 'pypy2', 'pypy3']
13+
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13', 'pypy3.9', 'pypy3.11']
1114

1215
steps:
13-
- uses: actions/checkout@v2
16+
- uses: actions/checkout@v4
1417
- name: Set up Python ${{ matrix.python-version }}
15-
uses: actions/setup-python@v2
18+
uses: actions/setup-python@v5
1619
with:
1720
python-version: ${{ matrix.python-version }}
1821
- name: Install dependencies
1922
run: |
2023
python -m pip install --upgrade pip
21-
pip install -e .
22-
pip install -r requirements-testing.txt
24+
pip install -e .[test]
2325
- name: Test with pytest
2426
run: |
2527
pytest test_mixpanel.py

BUILD.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,22 @@ Release process::
88
6. Rebuild docs and publish to GitHub Pages (if appropriate -- see below)
99
7. Publish to PyPI. (see below)
1010

11+
Install test and developer environment modules::
12+
pip install -e .[test,dev]
13+
1114
Run tests::
1215

13-
tox
16+
python -m tox - runs all tests against all configured environments in the pyproject.toml
1417

1518
Publish to PyPI::
1619

17-
pip install twine wheel
18-
python setup.py sdist bdist_wheel
19-
twine upload dist/*
20+
python -m build
21+
python -m twine upload dist/*
2022

2123
Build docs::
2224

23-
pip install sphinx
24-
python setup.py build_sphinx
25+
python -m sphinx -b html docs docs/_build/html
2526

2627
Publish docs to GitHub Pages::
2728

28-
pip install ghp-import
29-
ghp-import -n -p build/sphinx/html
29+
python -m ghp_import -n -p docs/_build/html

CHANGES.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
v4.11.0
2+
* Set minimum supported python version to 3.9, deprecating support for end-of-life versions of python
3+
* Convert setup.py to pyproject.toml
4+
15
v4.9.0
26
* To reduce TLS cert friction, use requests rather than directly using urllib3.
37
Reinstate TLS cert validation by default. (#103)

LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright 2013-2021 Mixpanel, Inc.
1+
Copyright 2013-2025 Mixpanel, Inc.
22

33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.

demo/subprocess_consumer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ def do_tracking(project_token, distinct_id, queue):
3838
'''
3939
consumer = QueueWriteConsumer(queue)
4040
mp = Mixpanel(project_token, consumer)
41-
for i in xrange(100):
41+
for i in range(100):
4242
event = 'Tick'
4343
mp.track(distinct_id, event, {'Tick Number': i})
44-
print 'tick {0}'.format(i)
44+
print(f'tick {i}')
4545

4646
queue.put(None) # tell worker we're out of jobs
4747

@@ -64,7 +64,7 @@ def do_sending(queue):
6464
if __name__ == '__main__':
6565
# replace token with your real project token
6666
token = '0ba349286c780fe53d8b4617d90e2d01'
67-
distinct_id = ''.join(random.choice('ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789') for x in xrange(32))
67+
distinct_id = ''.join(random.choice('ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789') for x in range(32))
6868

6969
queue = multiprocessing.Queue()
7070
sender = multiprocessing.Process(target=do_sending, args=(queue,))

mixpanel/__init__.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
Analytics updates. :class:`~.Consumer` and :class:`~.BufferedConsumer` allow
1515
callers to customize the IO characteristics of their tracking.
1616
"""
17-
from __future__ import absolute_import, unicode_literals
1817
import datetime
1918
import json
2019
import logging
@@ -23,11 +22,9 @@
2322

2423
import requests
2524
from requests.auth import HTTPBasicAuth
26-
import six
27-
from six.moves import range
2825
import urllib3
2926

30-
__version__ = '4.10.1'
27+
__version__ = '4.11.0'
3128
VERSION = __version__ # TODO: remove when bumping major version.
3229

3330
logger = logging.getLogger(__name__)
@@ -620,7 +617,7 @@ def _write_request(self, request_url, json_message, api_key=None, api_secret=Non
620617
verify=self._verify_cert,
621618
)
622619
except Exception as e:
623-
six.raise_from(MixpanelException(e), e)
620+
raise MixpanelException(e) from e
624621

625622
try:
626623
response_dict = response.json()
@@ -733,6 +730,6 @@ def _flush_endpoint(self, endpoint):
733730
mp_e = MixpanelException(orig_e)
734731
mp_e.message = batch_json
735732
mp_e.endpoint = endpoint
736-
six.raise_from(mp_e, orig_e)
733+
raise mp_e from orig_e
737734
buf = buf[self._max_size:]
738735
self._buffers[endpoint] = buf

pyproject.toml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
[build-system]
2+
requires = ["setuptools>=61.0", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "mixpanel"
7+
dynamic = ["version"]
8+
description = "Official Mixpanel library for Python"
9+
readme = "README.rst"
10+
license = "Apache-2.0"
11+
authors = [
12+
{name = "Mixpanel, Inc.", email = "dev@mixpanel.com"},
13+
]
14+
requires-python = ">=3.9"
15+
dependencies = [
16+
"requests>=2.32.5",
17+
]
18+
keywords = ["mixpanel", "analytics"]
19+
classifiers = [
20+
"Operating System :: OS Independent",
21+
"Programming Language :: Python :: 3",
22+
"Programming Language :: Python :: 3.9",
23+
"Programming Language :: Python :: 3.10",
24+
"Programming Language :: Python :: 3.11",
25+
"Programming Language :: Python :: 3.12",
26+
"Programming Language :: Python :: 3.13",
27+
]
28+
29+
[project.urls]
30+
Homepage = "https://github.com/mixpanel/mixpanel-python"
31+
32+
[project.optional-dependencies]
33+
test = [
34+
"pytest>=8.4.1",
35+
"responses>=0.25.8",
36+
]
37+
dev = [
38+
"tox>=4.28.4",
39+
"build",
40+
"twine",
41+
"sphinx",
42+
"ghp-import",
43+
]
44+
45+
[tool.setuptools.dynamic]
46+
version = {attr = "mixpanel.__version__"}
47+
48+
[tool.setuptools.packages.find]
49+
exclude = ["demo"]
50+
51+
[tool.tox]
52+
envlist = ["py39", "py310", "py311", "py312"]
53+
54+
[tool.tox.env_run_base]
55+
extras = ["test"]
56+
commands = [
57+
["pytest", "{posargs}"],
58+
]

requirements-testing.txt

Lines changed: 0 additions & 6 deletions
This file was deleted.

setup.cfg

Lines changed: 0 additions & 2 deletions
This file was deleted.

setup.py

Lines changed: 0 additions & 50 deletions
This file was deleted.

0 commit comments

Comments
 (0)