Skip to content

collector.VERSION constant from pyproject.toml via importlib.metadata#69

Merged
pda merged 1 commit intomainfrom
version-const-from-pyproject-toml
Jul 21, 2025
Merged

collector.VERSION constant from pyproject.toml via importlib.metadata#69
pda merged 1 commit intomainfrom
version-const-from-pyproject-toml

Conversation

@pda
Copy link
Member

@pda pda commented Jul 21, 2025

There should be a single source of truth for the version.

Prior to uv (#58) the setup.py file was loading the version attribute from the collector.VERSION constant... but pyproject.toml can't do that, so now we're doing it the other way around.

test-collector-python $ PYTHONPATH=src python -c 'from buildkite_test_collector.collector.constants import VERSION; print(VERSION)'
1.0.4

👌🏼

@pda pda requested review from a team and Copilot July 21, 2025 06:46
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 implements a single source of truth for version management by loading the version from pyproject.toml via importlib.metadata instead of hardcoding it in constants. The change ensures version consistency between the package metadata and the collector's runtime version reporting.

Key changes:

  • Replaces hardcoded version string with dynamic loading from package metadata
  • Updates collector name to use a consistent format with the new distribution name constant
  • Removes unused import in test file

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/buildkite_test_collector/collector/constants.py Implements dynamic version loading from package metadata with fallback handling
src/buildkite_test_collector/collector/run_env.py Updates collector name usage and removes pylint disable comment
tests/buildkite_test_collector/collector/test_run_env.py Removes unused RunEnv import

So that there's a single source of truth again; prior to uv the setup.py
file was loading the version from the constant... now we're doing it the
other way around.
@pda pda force-pushed the version-const-from-pyproject-toml branch from 0c1fbe3 to 87e74d7 Compare July 21, 2025 06:51
@pda pda merged commit 504ee8f into main Jul 21, 2025
10 checks passed
@pda pda deleted the version-const-from-pyproject-toml branch July 21, 2025 06:56
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.

2 participants