Closed Archetypically closed 3 years ago
No I hadn't considered a first class solution for semantic version strings. It kind of seems like a pretty specific use case. The easiest thing might be to support comparisons of arrays so you could do [1, 0, 1] < [2, 0]
which is supported by Python but not exposed through Rule Engine. I hadn't noticed until just now but you can't even do equality comparisons on arrays at this time (which are still pretty new). Issue with this solution is you'd need to convert your semantic version to an array of integers though.
That sounds like a reasonable, more widely applicable solution. I think needing to split my semver into an array of ints, then pass that input to rule-engine
is totally acceptable, as long as the array comparison is supported by rule-engine
. If I could +1 a to-do item then, that would totally satisfy my use case.
I'll see what I can do but it may not happen until November because October is Hacktoberfest which will take most of my FOSS dev time. Thanks for the suggestion!
This is done and available for testing in the feat/v2.3 branch. It'll be in the 2.3 version release which I'll probably finalize and publish within the next 1-3 weeks.
In [1]: import rule_engine; rule_engine.Rule('version > [1, 0, 0]').matches({'version': tuple(map(int, '1.2.0'.split('.')))})
Out[1]: True
This has been completed in version 2.3.0 which has now been published.
Hi @zeroSteiner ! Love the library, I've used it in a couple of personal projects.
Wondering if there's any thought or TODO item regarding semantic version comparison? Only the numbers, ignoring the label extensions (like
-beta
or-rc
).This can be done using using pure python:
(forgive my hasty two line example)
or using
packaging.version.parse
which is packaged withsetuptools
.I believe I can accomplish the same goal using custom resolvers (which I am planning on doing for my current project), but am curious as to the status of a first-class solution.