lib: py: remove distutils in favor of setuptools#3007
Conversation
As distutils is removed in python 3.12, and setuptools provides the same interface, it can be switched in place with minor changes. This allows using the thrift bindings on versions of Python 3.12 or greater.
ctubbsii
left a comment
There was a problem hiding this comment.
This is a small incremental improvement. However, it should also be done with other modernizations, like those described in https://packaging.python.org/en/latest/guides/modernize-setup-py-project/
|
Breaks build: https://ci.appveyor.com/project/ApacheSoftwareFoundation/thrift/builds/53103767 |
|
The CI runs on python 3.5(which has been deprecated since sep 2020) which does not have support for setuptools 59.0.0(released nov 2021), which is why this fails. CI even seems to use swtuptools 28.8.0, which was released in 2016! |
1 similar comment
|
The CI runs on python 3.5(which has been deprecated since sep 2020) which does not have support for setuptools 59.0.0(released nov 2021), which is why this fails. CI even seems to use swtuptools 28.8.0, which was released in 2016! |
…ds on setuptools < 69
thrift ships sdist-only, so every pip install builds lib/py/setup.py via the
PEP 517 in-process backend. setup.py calls sys.exit(0) on its build success
paths. setuptools' build_meta.run_setup() runs setup.py with exec(). On
setuptools < 69 the resulting SystemExit propagates and terminates the build
backend before it writes pip's result file:
OSError: [Errno 2] No such file or directory: '.../output.json'
setuptools >= 69 added a try/except SystemExit that swallows exit code 0 while
emitting a SetuptoolsDeprecationWarning: 'Running setup.py directly as CLI tool
is deprecated. Please avoid using sys.exit(0) or similar statements that don't
fit in the paradigm of a configuration file.' (see setuptools build_meta and
https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html). Because
thrift has no wheels, any environment with setuptools < 69 cannot install
thrift 0.23.0 (seen on runtime images bundling setuptools 68).
The sys.exit() calls were added incidentally in a715bdf (PR apache#3330,
'THRIFT-5923: UUID python', 2025-10-30) with no rationale in the commit, PR
description, or review. Before that commit setup.py used plain try/except
control flow with no sys.exit() and built on all setuptools versions.
Fix: restore the pre-apache#3330 control flow (try the C-extension build; on
BuildFailed fall back to the pure-Python build; let any remaining failure
propagate). No sys.exit() in setup.py. Behavior for consumers is unchanged.
Related: THRIFT-5915 / PR apache#3007 (distutils -> setuptools migration).
Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
…ds on setuptools < 69
thrift ships sdist-only, so every pip install builds lib/py/setup.py via the
PEP 517 in-process backend. setup.py calls sys.exit(0) on its build success
paths. setuptools' build_meta.run_setup() runs setup.py with exec(). On
setuptools < 69 the resulting SystemExit propagates and terminates the build
backend before it writes pip's result file:
OSError: [Errno 2] No such file or directory: '.../output.json'
setuptools >= 69 added a try/except SystemExit that swallows exit code 0 while
emitting a SetuptoolsDeprecationWarning: 'Running setup.py directly as CLI tool
is deprecated. Please avoid using sys.exit(0) or similar statements that don't
fit in the paradigm of a configuration file.' (see setuptools build_meta and
https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html). Because
thrift has no wheels, any environment with setuptools < 69 cannot install
thrift 0.23.0 (seen on runtime images bundling setuptools 68).
The sys.exit() calls were added incidentally in a715bdf (PR apache#3330,
'THRIFT-5923: UUID python', 2025-10-30) with no rationale in the commit, PR
description, or review. Before that commit setup.py used plain try/except
control flow with no sys.exit() and built on all setuptools versions.
Fix: restore the pre-apache#3330 control flow (try the C-extension build; on
BuildFailed fall back to the pure-Python build; let any remaining failure
propagate). No sys.exit() in setup.py. Behavior for consumers is unchanged.
Related: THRIFT-5915 / PR apache#3007 (distutils -> setuptools migration).
Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
…ds on setuptools < 69
thrift ships sdist-only, so every pip install builds lib/py/setup.py via the
PEP 517 in-process backend. setup.py calls sys.exit(0) on its build success
paths. setuptools' build_meta.run_setup() runs setup.py with exec(). On
setuptools < 69 the resulting SystemExit propagates and terminates the build
backend before it writes pip's result file:
OSError: [Errno 2] No such file or directory: '.../output.json'
setuptools >= 69 added a try/except SystemExit that swallows exit code 0 while
emitting a SetuptoolsDeprecationWarning: 'Running setup.py directly as CLI tool
is deprecated. Please avoid using sys.exit(0) or similar statements that don't
fit in the paradigm of a configuration file.' (see setuptools build_meta and
https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html). Because
thrift has no wheels, any environment with setuptools < 69 cannot install
thrift 0.23.0 (seen on runtime images bundling setuptools 68).
The sys.exit() calls were added incidentally in a715bdf (PR #3330,
'THRIFT-5923: UUID python', 2025-10-30) with no rationale in the commit, PR
description, or review. Before that commit setup.py used plain try/except
control flow with no sys.exit() and built on all setuptools versions.
Fix: restore the pre-#3330 control flow (try the C-extension build; on
BuildFailed fall back to the pure-Python build; let any remaining failure
propagate). No sys.exit() in setup.py. Behavior for consumers is unchanged.
Related: THRIFT-5915 / PR #3007 (distutils -> setuptools migration).
Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
As distutils is removed in python 3.12, and setuptools provides the same interface, it can be switched in place with only minor changes. This allows using the thrift bindings on versions of Python 3.12 or greater, and in python environments without distutils installed(such as NixOS, which does not expose setuptools' internal distutils distribution)
[skip ci]anywhere in the commit message to free up build resources.