Switch to pkg_resources for compatibility check
Plugin Manager now internally uses pkg_resources.parse_version and pkg_resources.parse_requirements to check for version compatibility with plugins from the repository. That will allow to directly use the OctoPrint version string once it's PEP440 compatible.
This commit is contained in:
parent
60043ccd1e
commit
8eb61a9926
1 changed files with 8 additions and 14 deletions
|
|
@ -520,25 +520,19 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||||
self._repository_plugins = map(map_repository_entry, repo_data)
|
self._repository_plugins = map(map_repository_entry, repo_data)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _is_octoprint_compatible(self, octoprint_version, compatibility_entries):
|
def _is_octoprint_compatible(self, octoprint_version_string, compatibility_entries):
|
||||||
"""
|
"""
|
||||||
Tests if the current ``octoprint_version`` is compatible to any of the provided ``compatibility_entries``.
|
Tests if the current ``octoprint_version`` is compatible to any of the provided ``compatibility_entries``.
|
||||||
"""
|
"""
|
||||||
import semantic_version
|
|
||||||
|
|
||||||
|
octoprint_version = pkg_resources.parse_version(octoprint_version_string)
|
||||||
for octo_compat in compatibility_entries:
|
for octo_compat in compatibility_entries:
|
||||||
for version_string in (octo_compat, ">={}".format(octo_compat)):
|
if not any(octo_compat.startswith(c) for c in ("<", "<=", "!=", "==", ">=", ">", "~=", "===")):
|
||||||
try:
|
octo_compat = ">={}".format(octo_compat)
|
||||||
s = semantic_version.Spec(version_string)
|
|
||||||
if semantic_version.Version(octoprint_version) in s:
|
s = next(pkg_resources.parse_requirements("OctoPrint" + octo_compat))
|
||||||
break
|
if octoprint_version in s:
|
||||||
except ValueError:
|
break
|
||||||
# that just means that octo_compat directly wasn't a valid version spec string, so we try
|
|
||||||
# prefixing that with ">=" next and check again
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
continue
|
|
||||||
break
|
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue