mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-29 17:47:14 +02:00
Check manifest engines field for PIO Core version
This commit is contained in:
@ -40,7 +40,12 @@ class AbortedByUser(PlatformioException):
|
||||
|
||||
class UnknownPlatform(PlatformioException):
|
||||
|
||||
MESSAGE = "Unknown platform '{0}'"
|
||||
MESSAGE = "Unknown development platform '{0}'"
|
||||
|
||||
|
||||
class IncompatiblePlatform(PlatformioException):
|
||||
|
||||
MESSAGE = "Development platform '{0}' is not compatible with PIO Core v{1}"
|
||||
|
||||
|
||||
class PlatformNotInstalledYet(PlatformioException):
|
||||
|
@ -24,7 +24,7 @@ import click
|
||||
import requests
|
||||
import semantic_version
|
||||
|
||||
from platformio import app, exception, telemetry, util
|
||||
from platformio import __version__, app, exception, telemetry, util
|
||||
from platformio.downloader import FileDownloader
|
||||
from platformio.unpacker import FileUnpacker
|
||||
from platformio.vcsclient import VCSClientFactory
|
||||
@ -75,6 +75,8 @@ class PackageRepoIterator(object):
|
||||
|
||||
class PkgRepoMixin(object):
|
||||
|
||||
PIO_VERSION = semantic_version.Version(util.pepver_to_semver(__version__))
|
||||
|
||||
@staticmethod
|
||||
def max_satisfying_repo_version(versions, requirements=None):
|
||||
item = None
|
||||
@ -87,9 +89,13 @@ 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 "system" in v and v['system'] not in ("all", "*") and \
|
||||
systype not in v['system']:
|
||||
continue
|
||||
if "platformio" in v.get("engines", {}):
|
||||
if PkgRepoMixin.PIO_VERSION not in semantic_version.Spec(
|
||||
v['engines']['platformio']):
|
||||
continue
|
||||
specver = semantic_version.Version(v['version'])
|
||||
if reqspec and specver not in reqspec:
|
||||
continue
|
||||
@ -462,9 +468,11 @@ class BasePkgManager(PkgRepoMixin, PkgInstallerMixin):
|
||||
package = self.get_package(name, requirements, url)
|
||||
return package.get("__pkg_dir") if package else None
|
||||
|
||||
def is_outdated(self, name, requirements=None):
|
||||
def is_outdated(self, name, requirements=None, silent=False):
|
||||
package_dir = self.get_package_dir(name, requirements)
|
||||
if not package_dir:
|
||||
if silent:
|
||||
return
|
||||
click.secho(
|
||||
"%s @ %s is not installed" % (name, requirements or "*"),
|
||||
fg="yellow")
|
||||
|
@ -20,8 +20,9 @@ from multiprocessing import cpu_count
|
||||
from os.path import basename, dirname, isdir, isfile, join
|
||||
|
||||
import click
|
||||
import semantic_version
|
||||
|
||||
from platformio import app, exception, util
|
||||
from platformio import __version__, app, exception, util
|
||||
from platformio.managers.package import BasePkgManager, PackageManager
|
||||
|
||||
|
||||
@ -91,8 +92,8 @@ class PlatformManager(BasePkgManager):
|
||||
self.cleanup_packages(p.packages.keys())
|
||||
return True
|
||||
|
||||
def is_outdated(self, name, requirements=None):
|
||||
if BasePkgManager.is_outdated(self, name, requirements):
|
||||
def is_outdated(self, name, requirements=None, silent=False):
|
||||
if BasePkgManager.is_outdated(self, name, requirements, silent):
|
||||
return True
|
||||
p = PlatformFactory.newPlatform(name, requirements)
|
||||
return p.are_outdated_packages()
|
||||
@ -249,11 +250,11 @@ class PlatformPackagesMixin(object):
|
||||
only_check)
|
||||
|
||||
def are_outdated_packages(self):
|
||||
for name, opts in self.get_installed_packages().items():
|
||||
version = self.packages[name].get("version", "")
|
||||
for name, opts in self.packages.items():
|
||||
version = opts.get("version", "")
|
||||
if not self.validate_version_requirements(version):
|
||||
continue
|
||||
if self.pm.is_outdated(name, version):
|
||||
if self.pm.is_outdated(name, version, silent=True):
|
||||
return True
|
||||
return False
|
||||
|
||||
@ -364,6 +365,7 @@ class PlatformRunMixin(object):
|
||||
|
||||
class PlatformBase(PlatformPackagesMixin, PlatformRunMixin):
|
||||
|
||||
PIO_VERSION = semantic_version.Version(util.pepver_to_semver(__version__))
|
||||
_BOARDS_CACHE = {}
|
||||
|
||||
def __init__(self, manifest_path):
|
||||
@ -378,6 +380,12 @@ class PlatformBase(PlatformPackagesMixin, PlatformRunMixin):
|
||||
self.silent = False
|
||||
self.verbose = False
|
||||
|
||||
if self.engines and "platformio" in self.engines:
|
||||
if self.PIO_VERSION not in semantic_version.Spec(
|
||||
self.engines['platformio']):
|
||||
raise exception.IncompatiblePlatform(self.name,
|
||||
str(self.PIO_VERSION))
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
return self._manifest['name']
|
||||
@ -410,6 +418,10 @@ class PlatformBase(PlatformPackagesMixin, PlatformRunMixin):
|
||||
def frameworks(self):
|
||||
return self._manifest.get("frameworks")
|
||||
|
||||
@property
|
||||
def engines(self):
|
||||
return self._manifest.get("engines")
|
||||
|
||||
@property
|
||||
def manifest(self):
|
||||
return self._manifest
|
||||
|
Reference in New Issue
Block a user