Check system compatibility for package

This commit is contained in:
Ivan Kravets
2017-12-27 21:36:45 +02:00
parent 5b7a0e6997
commit 0516cd74e1
2 changed files with 15 additions and 5 deletions

View File

@ -9,7 +9,10 @@ isort:
yapf:
yapf --recursive --in-place platformio/
before-commit: isort yapf lint
test:
py.test -v -s tests --ignore tests/test_examples.py --ignore tests/test_pkgmanifest.py
before-commit: isort yapf lint test
clean-docs:
rm -rf docs/_build

View File

@ -78,9 +78,15 @@ class PkgRepoMixin(object):
PIO_VERSION = semantic_version.Version(util.pepver_to_semver(__version__))
@staticmethod
def max_satisfying_repo_version(versions, requirements=None):
def is_system_compatible(valid_systems):
if valid_systems in (None, "all", "*"):
return True
if not isinstance(valid_systems, list):
valid_systems = list([valid_systems])
return util.get_systype() in valid_systems
def max_satisfying_repo_version(self, versions, requirements=None):
item = None
systype = util.get_systype()
reqspec = None
if requirements:
try:
@ -89,8 +95,7 @@ class PkgRepoMixin(object):
pass
for v in versions:
if "system" in v and v['system'] not in ("all", "*") and \
systype not in v['system']:
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(
@ -305,6 +310,8 @@ class PkgInstallerMixin(object):
continue
elif not pkg_id and manifest['name'] != name:
continue
elif not PkgRepoMixin.is_system_compatible(manifest.get("system")):
continue
# strict version or VCS HASH
if requirements and requirements == manifest['version']: