-
-
Notifications
You must be signed in to change notification settings - Fork 19
Added Swift Native Version Range Support and Associated Unit Tests #156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: PlayerIUnknown <[email protected]>
This solves the issue : "Add support for swift vers range" #132. Urging maintainers to review it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @PlayerIUnknown, see some suggestions below. Also make sure to go through the base VersionRange definition and take a look at other version range implementations like ConanVersionRange and NpmVersionRange.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be here, it belongs in version_range.py
.
class SwiftVersionRange(VersionRange): | ||
expression: str | ||
scheme: str = "swift" | ||
version_class: type = SwiftVersion |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about using SemverVersion
, if that's what the Swift version is?
version_class: type = SwiftVersion | |
version_class: type = versions.SemverVersion | |
def __attrs_post_init__(self): | ||
object.__setattr__(self, "constraints", self.parse(self.expression)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed? Aren’t we already taking care of it in the base VersionRange
class?
@staticmethod | ||
def parse(expression): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn’t correct, you need to implement from_native
.
def __str__(self): | ||
return f"vers:swift/{'|'.join([c.to_string() for c in self.constraints])}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a specific reason why we need to override the base str for swift?
@@ -0,0 +1,38 @@ | |||
import unittest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you links to actual example of these version ranges seen in the wild?
Overview
This pull request introduces support for Swift's native version ranges within the Univers project. Swift utilizes semantic versioning, and this update enables the handling of Swift package manager's specific version range declarations effectively. The update includes parsing logic for Swift version ranges and corresponding unit tests to ensure functionality adheres to Swift's versioning specifications.
Details
Swift's package manager allows specifying dependencies with various version range formats. This implementation supports the following native Swift version range specifications:
exact: "X.Y.Z"
, where the dependency must match an exact version.from: "X.Y.Z"
, indicating a minimum version up to the next major version but not including."X.Y.Z"..<"A.B.C"
to specify a range including the lower bound but excluding the upper bound."X.Y.Z"..."A.B.C"
to specify a range including both the lower and upper bounds.Modifications
tests/test_swift_versions.py
to verify parsing and handling of all supported version range specifications.Example Usage
The
SwiftVersionRange
can be instantiated with a Swift version range string:This will parse and prepare constraints that ensure compatibility checks against provided Swift package versions.
Testing
Unit tests cover:
Impact
This update allows developers using the Univers project to integrate Swift packages more seamlessly, adhering to Swift's native versioning schemes. It enhances the versatility of the Univers version range handling and ensures better cross-platform package management compatibility.