Skip to content

Conversation

@efahk
Copy link
Contributor

@efahk efahk commented Aug 20, 2025

This PR introduces some modernization changes for the python SDK

(1) Migrates the legacy setup.py build file to pyproject
i) Merges tox.ini into pyproject.toml.
ii) Removes the explicit requirements-testing.txt and adds a testing dependency node

(2) Sets the minimum version of support to python 3.9. All those <= 3.9 have been EOL for a while.

(3) Removes some unneeded dependencies.
i) Six is no longer needed for python 2 & 3 interop
ii) urllib isn't needed explicitly since it's now packaged with requests

  • Decided not to touch uv yet in this change

"responses>=0.25.8",
]
dev = [
"tox>=4.28.4",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still need tox?

Copy link
Contributor Author

@efahk efahk Aug 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to keep it around for now since tox's utility is just to abstract away looping over different python interpreter versions and running pytest against each

The alternative is scripting that ourselves. With UV, it'd probably look like for $py in [3.9,3.10,...]:uv run --python $py pytest

]
requires-python = ">=3.9"
dependencies = [
"requests>=2.32.5",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm 🤔 maybe it's time to try httpx? opens door for async support as well

Copy link
Contributor Author

@efahk efahk Aug 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea that door's definitely open now. I'll trial it with the incoming feature flag code in the next PR. Native async would be great

Copy link
Contributor

@hans-lizihan hans-lizihan Aug 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since its major version bump, prob do in the 5.0 release?

We can prob. tag a few rcs as well

@jaredmixpanel jaredmixpanel requested a review from Copilot August 20, 2025 20:39
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR modernizes the Mixpanel Python SDK by migrating from legacy setup.py to pyproject.toml configuration and dropping support for end-of-life Python versions.

  • Migrates build configuration from setup.py to pyproject.toml with tox configuration included
  • Sets minimum Python version to 3.9, removing support for Python 2.7 and 3.4-3.8
  • Removes outdated dependencies (six, urllib3) that are no longer needed for modern Python

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pyproject.toml New build configuration replacing setup.py with modern Python project structure
setup.py Removed legacy setup file
test_mixpanel.py Updated imports and test code to remove Python 2 compatibility layer
mixpanel/init.py Updated exception handling and removed six dependency
demo/subprocess_consumer.py Updated to use modern Python range() and f-strings
tox.ini Removed as configuration moved to pyproject.toml
requirements-testing.txt Removed as test dependencies moved to pyproject.toml
setup.cfg Removed legacy wheel configuration
.github/workflows/test.yml Updated CI to test only supported Python versions
BUILD.rst Updated build documentation for modern tooling
LICENSE.txt Updated copyright year to 2025
CHANGES.txt Added changelog entry for version 4.11.0

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

test_mixpanel.py Outdated

body = six.ensure_str(rsps.calls[0].request.body)
wrapper = dict(urllib.parse.parse_qsl(body))
#body = rsps.calls[0].request.body if isinstance(rsps.calls[0].request.body, str) else rsps.calls[0].request.body.decode('utf-8')
Copy link

Copilot AI Aug 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commented-out code should be removed rather than left as a comment to maintain code cleanliness.

Suggested change
#body = rsps.calls[0].request.body if isinstance(rsps.calls[0].request.body, str) else rsps.calls[0].request.body.decode('utf-8')

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@jaredmixpanel jaredmixpanel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@efahk efahk merged commit 19a1bbe into master Aug 22, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants