Skip to content
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

Setting 3.22 as maximum version in plugin metadata.txt is used as 3.22.0 (while we think it should be 3.22.99) #236

Open
rduivenvoorde opened this issue Jan 25, 2022 · 5 comments

Comments

@rduivenvoorde
Copy link
Contributor

Hi All,

recently Raymond published a plugin which had some issues with master version (3.23) so in it's metadata he defined a maximum version as:

qgisMaximumVersion=3.22

BUT users running QGIS 3.22 did not see it. Then in plugins.qgis.org we saw that the minimum version showed 3.22.0 so the people running 3.22.1 and 3.22.2 did not even see the plugin.

So our conclusion: apparently 3.22 was internally translated to 3.22.0 while we think that should be 3.22.99 or so?

Only if somebody defined 3.22.0 THEN it should use 3.22.0?

The alternative would be defining 3.23 but that would translate to 3.23.0 which would be shown in master?

@rduivenvoorde
Copy link
Contributor Author

rduivenvoorde commented Jan 26, 2022

@raymondnijssen Mmm, googling about how version numbering is handled normally, see PEP 440
https://www.python.org/dev/peps/pep-0440/#examples

It looks like 3.22 should be indeed interpreted as 3.22.0 if you use strict checking, but there is also a 'compatibility checking':
https://www.python.org/dev/peps/pep-0440/#compatible-release

The packaging version has some tools: https://packaging.pypa.io/en/latest/version.html

This is also used to handle all the version regimes in 'requirements.txt'

Some python code:

from packaging import version
>>> version.parse("3.22") <= version.parse("3.22.1")
True
>>> version.parse("3.22") == version.parse("3.22.1")
False
>>> version.parse("3.22") == version.parse("3.22.0")
True
>>> version.parse("3.22") == version.parse("3.22.1")
False

Then there is the ~= operator/specifier, to test the compatible release way...
See https://packaging.pypa.io/en/latest/specifiers.html

So you can set a specification and test Version's against it:

>>> from packaging import version
>>> v1 = version.parse("3.22")
>>> v2 = version.parse("3.22.1")
>>> from packaging.specifiers import SpecifierSet
>>> spec1 = SpecifierSet("~=3.22")
>>> v1 in spec1
True
>>> v2 in spec1
True

Let me look into @raymondnijssen example:

  • we have a plugin for which he defined: min-version=3.16 and max-version=3.22 I think that translated to a spec like:
>>> spec1 = SpecifierSet('>=3.16')
>>> spec2 = SpecifierSet('~=3.22')
>>> # combine
>>> combined_spec = spec1 & spec2
>>> combined_spec
<SpecifierSet('>=3.16,~=3.22')>
>>> from packaging.version import Version
>>> Version("3.16") in combined_spec
False  # MMmmmm.....
>>> spec3 = SpecifierSet('<=3.22.99')
>>> combined_spec = spec3 & spec1
>>> combined_spec
<SpecifierSet('<=3.22.99,>=3.16')>
>>> Version("3.16") in combined_spec
True
>>> Version("3.16.0") in combined_spec
True
>>> Version("3.22") in combined_spec
True
>>> Version("3.22.5") in combined_spec
True
>>> Version("3.22.100") in combined_spec
False
>>> Version("3") in combined_spec
False
>>> Version("3.15.9999") in combined_spec
False

@sumandari I updated the code above, I think this is very usable?

@raymondnijssen
Copy link

In that case maybe somehow specifying this in the example metadata.txt comment would help?

BTW, as a human I disagree with normal/formal version numbering. If someone tells me that a plugin works in 3.16, I would be surprised that it does not work in 3.16.4

@sumandari
Copy link
Collaborator

@rduivenvoorde @raymondnijssen I submitted a PR #224 for this issue, but haven't merged it yet. Would you please look into it and give your feedback? Thank you

@rduivenvoorde
Copy link
Contributor Author

This is actually a duplicate of #223

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants