-
Notifications
You must be signed in to change notification settings - Fork 4.1k
THRIFT-5915: Fix Python 3.12 build issues in thrift Python #3276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
b70cdb9 to
ea60e94
Compare
| try: | ||
| from setuptools import setup, Extension | ||
| except: | ||
| from distutils.core import setup, Extension, Command |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we keep this (but remove Command, looks like that's unused) as fallback for earlier versions of python? (although I'm not familiar of what scenario will have no setuptools but distutils)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking a look, @fishy! Do you know what the Thrift support guidelines are for older python versions? e.g. We have a followup PR to add better type support, ty type checking, etc. but that's dependent on more modern python versions. The guidelines in LANGUAGES.md appear pretty outdated (i.e. python 3.6.8 is the latest supported).
Would we be open to specifying that EOL python versions are not supported (currently 3.9 and older are EOL, with 3.10 scheduled to go EOL in October 2026)? That would make it much easier to evolve type support and modernize the codebase.
In this case, I think relying on setuptools >= 61.0 and dropping distutils limits us to python 3.7+, which seems very reasonable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there's no single support guideline for older language versions (each language has their own), but don't support EOL versions is a very reasonable and common approach.
| try: | ||
| from setuptools import setup, Extension | ||
| except Exception: | ||
| from distutils.core import setup, Extension |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same question here regarding fallback to earlier versions of python
ea60e94 to
ed73c20
Compare
switching to just building as a source allows us to patch in apache/thrift#3276 once that has landed/published we can switch back to pypi Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: phlax <454682+phlax@users.noreply.github.com>
| run: make -C test/py check | ||
|
|
||
| lib-python-macos: | ||
| needs: compiler-macos |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this also be a matrix instead? (I'm not familiar with github actions enough so it's totally fine if this is not supported)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fishy Thanks - let me give it a try.
.github/workflows/build.yml
Outdated
| runs-on: macos-14 | ||
| strategy: | ||
| matrix: | ||
| python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if needs cannot be a matrix, I wonder whether we can define this as a "variable" somewhere in this yaml, so when we change the supported python versions in the future we only need to change one place.
.github/workflows/build.yml
Outdated
|
|
||
| - name: Python setup | ||
| run: | | ||
| python -m pip install --upgrade pip setuptools wheel flake8 tornado twisted zope.interface |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similar here on possibility to define the list as a variable
- Add pyproject.toml with setuptools build requirement for PEP 517 compliance - Replace distutils imports with setuptools equivalents - Use setuptools error names directly (CompileError, ExecError, PlatformError) - Fix macOS header collision with ntohll/htonll macros in endian.h This fixes the ModuleNotFoundError: No module named 'distutils' error when building thrift with Python 3.12+. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
c6f9e1f to
fc04dad
Compare
The system bison (2.3) doesn't support the %code directive. Add homebrew's bison to GITHUB_PATH so it persists across all steps. Co-Authored-By: Claude <noreply@anthropic.com>
…ck a matrix of python versions.
make -C test/cpp TestServer
src/TestServer.cpp:599:9: error: no viable conversion from '__bind<int &, sockaddr *, unsigned long>' to 'int'
599 | int rv = bind(socket_fd, (struct sockaddr*)&sa, sizeof(sa));
| ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4daefe5 to
9dc0b35
Compare
|
@fishy - I think this is ready for another look. I have another PR I'm working on for THRIFT-5537 - "drop eol python versions" - but it probably makes sense to keep that separate. Thanks! |
JIRA link for THRIFT-5915
Summary:
Why:
Validation:
Related issues:
N.B.: there are multiple commits at the moment but I will squash them to a single commit before merge per guidelines.