fix(setup.py): accept FlyDSL dev/rc builds when version matches pinned release#2664
fix(setup.py): accept FlyDSL dev/rc builds when version matches pinned release#2664
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
|
There was a problem hiding this comment.
Pull request overview
This PR updates the develop-mode FlyDSL version check in setup.py so that local/dev/rc builds of FlyDSL (e.g., 0.1.2.dev*) are treated as compatible with a pinned 0.1.2 release, avoiding unnecessary pip install flydsl==... during editable installs.
Changes:
- Add
_flydsl_matches_pinned()that compares parsed versions viapackaging.version.Version. - Use the helper in the develop-mode FlyDSL validation logic and precompute the pinned version string.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| """Same X.Y.Z as pin, allowing dev/rc/post/local segments (e.g. 0.1.2.dev462 == 0.1.2).""" | ||
| try: | ||
| from packaging.version import Version | ||
| except ImportError: | ||
| return installed_ver == pinned_ver | ||
| return Version(installed_ver).release == Version(pinned_ver).release |
There was a problem hiding this comment.
_flydsl_matches_pinned() compares Version(...).release, which ignores the PEP 440 epoch. That means versions like 1!0.1.2 would be treated as matching a pinned 0.1.2, even though the epoch changes version semantics. Consider comparing Version(...).base_version (or (epoch, release)) instead, which still ignores dev/rc/post/local segments but preserves epoch correctness (similar normalization is used elsewhere in the repo).
| """Same X.Y.Z as pin, allowing dev/rc/post/local segments (e.g. 0.1.2.dev462 == 0.1.2).""" | |
| try: | |
| from packaging.version import Version | |
| except ImportError: | |
| return installed_ver == pinned_ver | |
| return Version(installed_ver).release == Version(pinned_ver).release | |
| """Same pinned base version, allowing dev/rc/post/local segments while preserving epoch.""" | |
| try: | |
| from packaging.version import Version | |
| except ImportError: | |
| return installed_ver == pinned_ver | |
| return Version(installed_ver).base_version == Version(pinned_ver).base_version |
Problem
In develop mode, setup.py ensures FlyDSL matches the pinned version by:
Reading the installed version with importlib.metadata.version("flydsl").
Comparing it to the pinned string (0.1.2).
On any mismatch or import error, running pip install flydsl==0.1.2.
For an editable/local FlyDSL install, the reported version is often 0.1.2.dev462 (or similar), which is not equal to the string "0.1.2", so the script always took the “mismatch” path and invoked pip install. That is unnecessary and can break workflows where:
Solution
Add _flydsl_matches_pinned(installed_ver, pinned_ver) that uses packaging.version.Version and compares the .release tuples (e.g. (0, 1, 2)), so 0.1.2, 0.1.2.dev462, and other suffixes on the same X.Y.Z are treated as matching the pin.
If packaging is not importable, fall back to the previous strict string comparison for safety.