Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes versioning in wheel distributions by enabling version information to persist when Git is unavailable. The changes ensure that VERSION.txt is created during distribution and can be read when building from an sdist package.
- Adds fallback to read version from VERSION.txt file when Git repository is unavailable
- Creates VERSION.txt in distribution packages via meson dist script
- Ensures output directory exists before writing VERSION.txt
Reviewed Changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| scripts/versioning/scm_version.py | Added VERSION.txt fallback for non-git environments and directory creation before file write |
| meson.build | Added dist script to write VERSION.txt into distribution packages |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| script_dir = os.path.dirname(os.path.abspath(__file__)) | ||
| version_file = os.path.join(script_dir, 'VERSION.txt') |
There was a problem hiding this comment.
The VERSION.txt path is hardcoded relative to the script location, but the meson.build script writes it to scripts/versioning/VERSION.txt relative to MESON_DIST_ROOT. This path mismatch will cause the fallback to fail when the script is executed from different locations or in installed packages.
| script_dir = os.path.dirname(os.path.abspath(__file__)) | |
| version_file = os.path.join(script_dir, 'VERSION.txt') | |
| version_file = os.path.join('scripts', 'versioning', 'VERSION.txt') |
| except Exception: | ||
| pass |
There was a problem hiding this comment.
The bare except Exception silently swallows all errors including IOError, PermissionError, and UnicodeDecodeError. This makes debugging difficult if the VERSION.txt file exists but cannot be read. Consider catching specific exceptions or logging the error.
| except Exception: | |
| pass | |
| except (OSError, IOError, PermissionError, UnicodeDecodeError) as e: | |
| print(f"Error reading VERSION.txt: {e}", file=sys.stderr) |
No description provided.