fix(setup.py): improve requirements parsing and require setuptools>=80.9.0 for Python 3.12 compatibility #46
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issues Solved
setuptools(notably, thecanonicalize_version()error).setup.pyregarding Python version and requirements parsing.pyinstead ofshas the code block language specifier forpipinstallation commands inREADME.md.Summary
This PR modernizes
setup.pyand updates documentation to ensure smooth installation and usage in Python 3.12 environments. It adds a minimum required version forsetuptools, improves requirements parsing, and updates the README to use the appropriate code block language specifier for installation commands.This PR specifically addresses Python 3.12 compatibility. From what I heard at last week's Beam Summit 2025, Python 3.13+ support is being addressed separately by the Apache Beam team.
Changes
setup.py
setuptools>=80.9.0to theinstall_requiresargument of thesetup()function to prevent thecanonicalize_version()error in Python 3.12 environments, referencing the dependency version enforced in the requirements file for "Apache Beam py312 container image".requirements.txtto filter out comments and empty lines.python_requires=">=3.8"constraint.1.0.0(now follows PEP 440 and standard semantic versioning).README.md
pytoshforpipinstallation commands.Testing
Python 3.12.pipandsetuptoolsto the latest versions.pip install -e ..TypeError: canonicalize_version() got an unexpected keyword argument 'strip_trailing_zero'error no longer occurs during installation.python -m unittest -vand confirmed all tests passed without error.Reproduction Steps
fix/setup-py-improvementsbranch:git clone https://github.com/apache/beam-starter-python.git cd beam-starter-python git checkout fix/setup-py-improvementspython3.12 -m venv venv source venv/bin/activatepipandsetuptools:pip install -e .Notes
WSL2 Ubuntu 22.04, Python 3.12.11, pip 25.1.1, setuptools 80.9.0.Python 3.12compatibility.Python 3.13+support is being handled separately by the Apache Beam team.Checklist
setup.pyfor Python 3.12 compatibility.pytoshforpipinstallation commands inREADME.md.