Added workaround for Python SemVer package's issue 61 with caret range and pre-releases

This commit is contained in:
Ivan Kravets
2018-07-03 14:55:48 +03:00
parent 6dada01e70
commit 25b562e1c1
3 changed files with 22 additions and 7 deletions

View File

@ -16,6 +16,7 @@ PlatformIO 3.0
(`issue #1665 <https://github.com/platformio/platformio-core/issues/1665>`_)
* Handle "architectures" data from "library.properties" manifest in
`lib_compat_mode = strict <http://docs.platformio.org/en/page/librarymanager/ldf.html#compatibility-mode>`__
* Added workaround for Python SemVer package's `issue #61 <https://github.com/rbarrois/python-semanticversion/issues/61>`_ with caret range and pre-releases
* Replaced conflicted "env" pattern by "sysenv" for `"platformio.ini" Dynamic Variables" <http://docs.platformio.org/page/projectconf/dynamic_variables.html>`__
(`issue #1705 <https://github.com/platformio/platformio-core/issues/1705>`_)
* Removed "date&time" when processing project with `platformio run <http://docs.platformio.org/page/userguide/cmd_run.html>`__ command

2
docs

Submodule docs updated: ae2968e52a...0b8ac5fbf7

View File

@ -90,7 +90,8 @@ class PkgRepoMixin(object):
reqspec = None
if requirements:
try:
reqspec = semantic_version.Spec(requirements)
reqspec = self.parse_semver_spec(
requirements, raise_exception=True)
except ValueError:
pass
@ -98,8 +99,8 @@ class PkgRepoMixin(object):
if not self.is_system_compatible(v.get("system")):
continue
if "platformio" in v.get("engines", {}):
if PkgRepoMixin.PIO_VERSION not in semantic_version.Spec(
v['engines']['platformio']):
if PkgRepoMixin.PIO_VERSION not in self.parse_semver_spec(
v['engines']['platformio'], raise_exception=True):
continue
specver = semantic_version.Version(v['version'])
if reqspec and specver not in reqspec:
@ -224,7 +225,20 @@ class PkgInstallerMixin(object):
@staticmethod
def parse_semver_spec(value, raise_exception=False):
try:
return semantic_version.Spec(value)
# Workaround for ^ issue and pre-releases
# https://github.com/rbarrois/python-semanticversion/issues/61
requirements = []
for item in str(value).split(","):
item = item.strip()
if not item:
continue
if item.startswith("^"):
major = semantic_version.Version.coerce(item[1:]).major
requirements.append(">=%s" % major)
requirements.append("<%s" % (int(major) + 1))
else:
requirements.append(item)
return semantic_version.Spec(*requirements)
except ValueError as e:
if raise_exception:
raise e
@ -480,8 +494,8 @@ class PkgInstallerMixin(object):
"Package version %s doesn't satisfy requirements %s" %
(tmp_manifest['version'], requirements))
try:
assert tmp_semver and tmp_semver in semantic_version.Spec(
requirements), mismatch_error
assert tmp_semver and tmp_semver in self.parse_semver_spec(
requirements, raise_exception=True), mismatch_error
except (AssertionError, ValueError):
assert tmp_manifest['version'] == requirements, mismatch_error