Skip to content

Conversation

@BorisQuanLi
Copy link

@BorisQuanLi BorisQuanLi commented Jul 14, 2025

Issues Solved

  • Packaging errors in Python 3.12 environments due to outdated setuptools (notably, the canonicalize_version() error).
  • Lack of clarity and constraints in setup.py regarding Python version and requirements parsing.
  • Use of py instead of sh as the code block language specifier for pip installation commands in README.md.

Summary

This PR modernizes setup.py and updates documentation to ensure smooth installation and usage in Python 3.12 environments. It adds a minimum required version for setuptools, 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

  1. setup.py

    • Added setuptools>=80.9.0 to the install_requires argument of the setup() function to prevent the canonicalize_version() error in Python 3.12 environments, referencing the dependency version enforced in the requirements file for "Apache Beam py312 container image".
    • Improved parsing of requirements.txt to filter out comments and empty lines.
    • Updated package name to follow kebab-case convention.
    • Added python_requires=">=3.8" constraint.
    • Improved version string format to 1.0.0 (now follows PEP 440 and standard semantic versioning).
  2. README.md

    • Changed code block language specifier from py to sh for pip installation commands.

Testing

  • Created a virtual environment with Python 3.12.
  • Upgraded pip and setuptools to the latest versions.
  • Successfully installed the package with pip install -e ..
  • Verified that the TypeError: canonicalize_version() got an unexpected keyword argument 'strip_trailing_zero' error no longer occurs during installation.
  • Ran python -m unittest -v and confirmed all tests passed without error.

Reproduction Steps

  1. Clone the repository and switch to the fix/setup-py-improvements branch:
    git clone https://github.com/apache/beam-starter-python.git
    cd beam-starter-python
    git checkout fix/setup-py-improvements
  2. Create a Python 3.12 virtual environment:
    python3.12 -m venv venv
    source venv/bin/activate
  3. Upgrade pip and setuptools:
    pip install --upgrade pip setuptools
  4. Install the package:
    pip install -e .
  5. (Optional) Attempt to run tests:
    python -m unittest -v

Notes

  • Platform details: WSL2 Ubuntu 22.04, Python 3.12.11, pip 25.1.1, setuptools 80.9.0.
  • This PR is focused on Python 3.12 compatibility. Python 3.13+ support is being handled separately by the Apache Beam team.

Checklist

  • Modernized setup.py for Python 3.12 compatibility.
  • Changed code block language specifier from py to sh for pip installation commands in README.md.
  • Verified installation in a Python 3.12 virtual environment.

@BorisQuanLi BorisQuanLi changed the title fix(setup.py): modernize packaging and require setuptools>=80.9.0 for Python 3.12 compatibility fix(setup.py): improve requirements parsing and require setuptools>=80.9.0 for Python 3.12 compatibility Jul 14, 2025
- Add proper requirements.txt parsing with comment filtering
- Update package name to follow kebab-case convention
- Add python_requires constraint (>=3.8)
- Improve version string format (1.0.0)

This resolves packaging compatibility issues encountered when
installing with pip in Python 3.12+ environments.
Fix markdown syntax highlighting for installation commands
to reflect the improved Python 3.12 compatibility workflow.
- Add setuptools>=80.9.0 to install_requires to resolve packaging errors in Python 3.12 environments.
- Ensures installation works with modern setuptools and avoids canonicalize_version errors.
@BorisQuanLi BorisQuanLi force-pushed the fix/setup-py-improvements branch from 52941e4 to 71ae133 Compare July 14, 2025 18:50
@BorisQuanLi BorisQuanLi marked this pull request as ready for review July 14, 2025 19:47
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.

1 participant