-
Notifications
You must be signed in to change notification settings - Fork 994
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
[bug] version range selection from pre-release order #17631
Comments
Hi @mrjoel This is something that we thoroughly discussed and iterated, based on user feedback and expectations.
The logic is that
Likewise, the So the logic to include and exclude them is correct. I'll also like to clarify that in Conan 2, hardcoding the resolution to prereleases in I'll give an example that makes this more evident:
Then, it was concluded that even if |
That seems somewhat unfortunate and non-intuitive from a SemVer perspective (1.0[.0] is a specific version, not a collection of multiple versions), but appears to be at least mostly self-consistent. Unless I'm missing something, however, that seems to prevent any range expression distinction based on pre-release values? For example, it appears that one can't write an expression that allows I'd expect to be able to do something like: from conan import ConanFile
class PackageC(ConanFile):
name = "packagec"
version = "2.1.0-beta" class PackageD(ConanFile):
name = "packaged"
version = "1.0.0"
def requirements(self):
self.requires(
# What I might really want to write, assuming the "alpha is a 2.1.0 release" logic.
#"packagec/[=2.1.0, include_prereleases]"
# Using a ranged comparator seems required to permit selection.
"packagec/[<=2.1.0, include_prereleases]"
# But - only for less-than-equal, not greater-than-equal?!?
#"packagec/[=>2.1.0, include_prereleases]"
# Can't set pre-release lower bound though.
#"packagec/[>=2.1.0-beta <=2.1.0, include_prereleases]"
# At best, something approximate like so, but also undesirably includes e.g., -alpha.
#"packagec/[>2.0.99 <=2.1.0, include_prereleases]"
# Also works (still not excluding -alpha), although quite
# non intuitively if expecting a total ordering.
"packagec/[>=2.1.0 <=2.1.0, include_prereleases]"
) This has been important for us with our internal dependencies (detailed below) to more strongly signal to a developer that no compatible version is available and needs to be updated from a remote. Since that is the case, I'd suggest that at least a documentation update would be important in order to clarify those semantics of range expression comparisons for pre-release and build metadata version sections. In particular, based on my updated understanding, it would be important to clarify the following (adjusted for correctness as needed):
I'd further suggest that it would still be greatly beneficial to have finer control within a given pre-release range for a single base version, specifically the ability to have comparators do full (pedantic?) SemVer ordering. If it were added, it would seem to need to be an additional range expression option (
I've seen that and looked into it, however it seems to only enable an all-or-nothing approach (there isn't anything like a The pattern we use for this is to have a intermediate meta package which serves as the primary source of requirements. The actual product source conanfile only depends on a matching version of that single dependency meta package. We allow each to develop concurrently, and use git tags to highlight incompatibility points (API changes, etc.) within a development cycle. Both the meta package version as well as the range expression is dynamically determined based on the particular git commit being used. If a developer is building a development version of the product from git, then we want to be able to specify including prerelease versions for the dependency metapackage, but not other packages, including packages for other products that may also be in the local cache. To do this, we regularly rev dependencies within a development cycle, but only update the dependency when incompatible changes are made, for which we rev the first prerelease as a quasi API compatibility flag within the dev cycle. For example, if moving from using I illustrate below a possible flow within a given development cycle which is enabled by this. It illustrates the pattern - we in no way always have all or even most of the transitions in each cycle, but having the structure to be able to increment when and as needed has been quite beneficial.
|
Hi @mrjoel
Not sure what you mean, I can add these cases to the test suite, and it works: # Limits
['>=2.1.0-beta', False, ["2.1.0"], ["2.1.0-beta", "2.1.0-alpha"]],
['>=2.1.0-beta', True, ["2.1.0-beta", "2.1.0-gamma"], ["2.1.0-alpha"]],
])
def test_range_prereleases_conf(version_range, resolve_prereleases, versions_in, versions_out): Where As you can see, if not using prereleases, I am adding this case in the test in PR, just in case. |
Describe the bug
In Conan 2 the version range selection criteria with pre-release versions differs from Conan 1. That's not itself problematic, however it appears that the Conan 2 behavior is incorrect with regards to SemVer semantics. Based on my investigation I'm suggesting that the bug is both in code and the docs.
Specifically, SemVer 2.0 11.3 stipulates that
We use a package with automatic version assignment based on git for development snapshots of dependencies. We add pre-release tags to indicate development towards the next anticipated release, but since it's developmental we don't want to have the final tag be a suitable version. (We may also add reved pre-release tags several times as an indicator for when compatibility boundaries occur within the development cycle).
As noted on the version ranges page, pre-release versions can be nuanced. I'm also checking my expectations, but there does seem to be an issue here. I don't make the suggestion lightly; notably, I'll acknowledge that I'm also suggesting that semver-checker is also wrong when comparing pre-release versions by strict less-than operator (including for the specific example in SemVer 11.3).
The following two example files illustrate my expectation. The dependency works in Conan 1, but Conan 2 doesn't match on the strictly less than operator.
As for documentation, the following pages appear to have inconsistencies/inaccuracies.
version ranges page
The green important admonition early in the page is correct when it states
However, when discussing the
include_prerelease
option later in the page, it seems incorrect to state that for the example expressionrequires = "pkg/[>1 <2, include_prerelease]"
that1.0-pre.1
should be included, or that2.0-pre1
should be excluded. Strictly speaking,1.0-pre.1
is earlier than>1
should allow, and2.0-pre1
is definitely earlier (less) than the full 2.0.0 release implied by<2
.requires
attributeSimilarly, the pre-releases table of examples is not as I'd expect either.
[>=1.0 <2]
, the value1.0.0-pre.1
should not be included, while2.0-pre.1
should be[<3.2.1]
, the value3.2.1-pre.1
should be includedHow to reproduce it
No response
The text was updated successfully, but these errors were encountered: