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