Skip to content

Replace VERSION.TXT parsing with importlib.metadata for Drake version detection#573

Merged
RussTedrake merged 3 commits intomasterfrom
copilot/remove-version-txt-dependency
May 2, 2026
Merged

Replace VERSION.TXT parsing with importlib.metadata for Drake version detection#573
RussTedrake merged 3 commits intomasterfrom
copilot/remove-version-txt-dependency

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 2, 2026

GetDrakeVersion() and DrakeVersionGreaterThan() relied on reading a VERSION.TXT file from disk, which only exists for certain Drake install types and breaks for others (pip, rules_python, source builds, etc.).

Changes

  • GetDrakeVersion(): Replaced VERSION.TXT file parsing with importlib.metadata.version("drake"). Returns "source" on PackageNotFoundError (e.g. unregistered source installs).
  • DrakeVersionGreaterThan(): Now delegates to GetDrakeVersion() instead of re-reading the file. Updated nightly version parsing to handle the "0.0.YYYYMMDD" format returned by importlib.metadata (previously parsed a "YYYYMMDDHHMMSS" string from VERSION.TXT).
  • Removed unused from pathlib import Path import.
import importlib.metadata
importlib.metadata.version("drake")  # "1.52.1" or "0.0.20260303" for nightlies

This change is Reviewable

Copilot AI linked an issue May 2, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Remove dependency on VERSION.TXT for Drake version retrieval Replace VERSION.TXT parsing with importlib.metadata for Drake version detection May 2, 2026
Copilot AI requested a review from RussTedrake May 2, 2026 11:28
@RussTedrake RussTedrake marked this pull request as ready for review May 2, 2026 11:32
Copy link
Copy Markdown
Owner

@RussTedrake RussTedrake left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

@RussTedrake made 1 comment.
Reviewable status: 0 of 1 files reviewed, all discussions resolved.

Copy link
Copy Markdown
Owner

@RussTedrake RussTedrake left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RussTedrake reviewed 1 file and all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on copilot[bot]).

@RussTedrake RussTedrake merged commit cdb8c90 into master May 2, 2026
6 checks passed
@RussTedrake RussTedrake deleted the copilot/remove-version-txt-dependency branch May 2, 2026 11:57
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.

GetDrakeVersion doesn't need VERSION.TXT

3 participants