forked from platformio/platformio-core
Move core packages to the one place; Bump to 3.0.0a17
This commit is contained in:
@ -14,7 +14,7 @@
|
||||
|
||||
import sys
|
||||
|
||||
VERSION = (3, 3, "0a16")
|
||||
VERSION = (3, 3, "0a17")
|
||||
__version__ = ".".join([str(s) for s in VERSION])
|
||||
|
||||
__title__ = "platformio"
|
||||
|
@ -16,14 +16,15 @@ from __future__ import absolute_import
|
||||
|
||||
from os.path import join, sep
|
||||
|
||||
from platformio.managers.core import get_core_package_dir
|
||||
|
||||
|
||||
def ProcessTest(env):
|
||||
env.Append(
|
||||
CPPDEFINES=["UNIT_TEST", "UNITY_INCLUDE_CONFIG_H"],
|
||||
CPPPATH=[join("$BUILD_DIR", "UnityTestLib")])
|
||||
unitylib = env.BuildLibrary(
|
||||
join("$BUILD_DIR", "UnityTestLib"),
|
||||
env.PioPlatform().get_package_dir("tool-unity"))
|
||||
join("$BUILD_DIR", "UnityTestLib"), get_core_package_dir("tool-unity"))
|
||||
env.Prepend(LIBS=[unitylib])
|
||||
|
||||
src_filter = None
|
||||
|
@ -18,7 +18,7 @@ import sys
|
||||
|
||||
import click
|
||||
|
||||
from platformio.pioplus import pioplus_call
|
||||
from platformio.managers.core import pioplus_call
|
||||
|
||||
|
||||
@click.group("account", short_help="Manage PIO Account")
|
||||
|
@ -23,7 +23,7 @@ import click
|
||||
|
||||
from platformio import exception, util
|
||||
from platformio.commands.device import device_monitor as cmd_device_monitor
|
||||
from platformio.pioplus import pioplus_call
|
||||
from platformio.managers.core import pioplus_call
|
||||
|
||||
# pylint: disable=unused-argument
|
||||
|
||||
|
@ -17,7 +17,7 @@ from os import getcwd
|
||||
|
||||
import click
|
||||
|
||||
from platformio.pioplus import pioplus_call
|
||||
from platformio.managers.core import pioplus_call
|
||||
|
||||
|
||||
@click.command("test", short_help="Local Unit Testing")
|
||||
|
@ -16,8 +16,8 @@ import click
|
||||
|
||||
from platformio.commands.lib import lib_update as cmd_lib_update
|
||||
from platformio.commands.platform import platform_update as cmd_platform_update
|
||||
from platformio.managers.core import update_core_packages
|
||||
from platformio.managers.lib import LibraryManager
|
||||
from platformio.pioplus import pioplus_update
|
||||
|
||||
|
||||
@click.command(
|
||||
@ -29,10 +29,12 @@ from platformio.pioplus import pioplus_update
|
||||
help="Do not update, only check for new version")
|
||||
@click.pass_context
|
||||
def cli(ctx, only_check):
|
||||
update_core_packages(only_check)
|
||||
|
||||
click.echo()
|
||||
click.echo("Platform Manager")
|
||||
click.echo("================")
|
||||
ctx.invoke(cmd_platform_update, only_check=only_check)
|
||||
pioplus_update()
|
||||
|
||||
click.echo()
|
||||
click.echo("Library Manager")
|
||||
|
@ -29,9 +29,9 @@ from platformio.commands.platform import \
|
||||
platform_uninstall as cmd_platform_uninstall
|
||||
from platformio.commands.platform import platform_update as cmd_platform_update
|
||||
from platformio.commands.upgrade import get_latest_version
|
||||
from platformio.managers.core import update_core_packages
|
||||
from platformio.managers.lib import LibraryManager
|
||||
from platformio.managers.platform import PlatformFactory, PlatformManager
|
||||
from platformio.pioplus import pioplus_update
|
||||
|
||||
|
||||
def in_silence(ctx=None):
|
||||
@ -157,18 +157,17 @@ def after_upgrade(ctx):
|
||||
else:
|
||||
click.secho("Please wait while upgrading PlatformIO...", fg="yellow")
|
||||
app.clean_cache()
|
||||
|
||||
# Update PlatformIO's Core packages
|
||||
update_core_packages()
|
||||
|
||||
u = Upgrader(last_version, __version__)
|
||||
if u.run(ctx):
|
||||
app.set_state_item("last_version", __version__)
|
||||
|
||||
# update PlatformIO Plus tool if it's installed
|
||||
pioplus_update()
|
||||
|
||||
click.secho(
|
||||
"PlatformIO has been successfully upgraded to %s!\n" %
|
||||
__version__,
|
||||
fg="green")
|
||||
|
||||
telemetry.on_event(
|
||||
category="Auto",
|
||||
action="Upgrade",
|
||||
|
@ -20,21 +20,18 @@ from os.path import join
|
||||
from platformio import exception, util
|
||||
from platformio.managers.package import PackageManager
|
||||
|
||||
PACKAGE_DEPS = {
|
||||
"pysite": {
|
||||
"name": "pysite-pioplus",
|
||||
"requirements": ">=0.3.0,<2"
|
||||
},
|
||||
"tool": {
|
||||
"name": "tool-pioplus",
|
||||
"requirements": ">=0.6.10,<2"
|
||||
}
|
||||
CORE_PACKAGES = {
|
||||
"project-templates": "*",
|
||||
"pysite-pioplus": ">=0.3.0,<2",
|
||||
"tool-pioplus": ">=0.6.10,<2",
|
||||
"tool-unity": "~1.20302.1",
|
||||
"tool-scons": "~3.20501.2"
|
||||
}
|
||||
|
||||
AUTO_UPDATES_MAX = 100
|
||||
PIOPLUS_AUTO_UPDATES_MAX = 100
|
||||
|
||||
|
||||
class PioPlusPackageManager(PackageManager):
|
||||
class CorePackageManager(PackageManager):
|
||||
|
||||
def __init__(self):
|
||||
PackageManager.__init__(
|
||||
@ -46,30 +43,28 @@ class PioPlusPackageManager(PackageManager):
|
||||
])
|
||||
|
||||
|
||||
def pioplus_install():
|
||||
pm = PioPlusPackageManager()
|
||||
for item in PACKAGE_DEPS.values():
|
||||
if not pm.get_package(item['name'], item['requirements']):
|
||||
pm.install(item['name'], item['requirements'])
|
||||
def get_core_package_dir(name):
|
||||
assert name in CORE_PACKAGES
|
||||
requirements = CORE_PACKAGES[name]
|
||||
pm = CorePackageManager()
|
||||
pkg_dir = pm.get_package_dir(name, requirements)
|
||||
if pkg_dir:
|
||||
return pkg_dir
|
||||
return pm.install(name, requirements)
|
||||
|
||||
|
||||
def pioplus_update():
|
||||
pm = PioPlusPackageManager()
|
||||
for item in PACKAGE_DEPS.values():
|
||||
pkg_dir = pm.get_package_dir(item['name'])
|
||||
if pkg_dir and pm.outdated(pkg_dir, item['requirements']):
|
||||
pm.update(item['name'], item['requirements'])
|
||||
def update_core_packages(only_check=False):
|
||||
pm = CorePackageManager()
|
||||
for name, requirements in CORE_PACKAGES.items():
|
||||
pkg_dir = pm.get_package_dir(name)
|
||||
if pkg_dir and pm.outdated(pkg_dir, requirements):
|
||||
pm.update(name, requirements, only_check=only_check)
|
||||
|
||||
|
||||
def pioplus_call(args, **kwargs):
|
||||
pioplus_install()
|
||||
pm = PioPlusPackageManager()
|
||||
pioplus_path = join(
|
||||
pm.get_package_dir(PACKAGE_DEPS['tool']['name'],
|
||||
PACKAGE_DEPS['tool']['requirements']), "pioplus")
|
||||
pioplus_path = join(get_core_package_dir("tool-pioplus"), "pioplus")
|
||||
os.environ['PYTHONEXEPATH'] = util.get_pythonexe_path()
|
||||
os.environ['PYTHONPYSITEDIR'] = pm.get_package_dir(
|
||||
PACKAGE_DEPS['pysite']['name'], PACKAGE_DEPS['pysite']['requirements'])
|
||||
os.environ['PYTHONPYSITEDIR'] = get_core_package_dir("pysite-pioplus")
|
||||
util.copy_pythonpath_to_osenv()
|
||||
code = subprocess.call([pioplus_path] + args, **kwargs)
|
||||
|
||||
@ -83,8 +78,8 @@ def pioplus_call(args, **kwargs):
|
||||
setattr(pioplus_call, count_attr, 1)
|
||||
count_value += 1
|
||||
setattr(pioplus_call, count_attr, count_value)
|
||||
if count_value < AUTO_UPDATES_MAX:
|
||||
pioplus_update()
|
||||
if count_value < PIOPLUS_AUTO_UPDATES_MAX:
|
||||
update_core_packages()
|
||||
return pioplus_call(args, **kwargs)
|
||||
|
||||
# handle reload request
|
@ -387,9 +387,10 @@ class PkgInstallerMixin(object):
|
||||
if not isdir(src_dir):
|
||||
os.makedirs(src_dir)
|
||||
src_manifest_path = join(src_dir, self.SRC_MANIFEST_NAME)
|
||||
_data = data
|
||||
_data = {}
|
||||
if isfile(src_manifest_path):
|
||||
_data.update(util.load_json(src_manifest_path))
|
||||
_data = util.load_json(src_manifest_path)
|
||||
_data.update(data)
|
||||
with open(src_manifest_path, "w") as fp:
|
||||
json.dump(_data, fp)
|
||||
|
||||
|
@ -23,6 +23,7 @@ import click
|
||||
import semantic_version
|
||||
|
||||
from platformio import __version__, app, exception, util
|
||||
from platformio.managers.core import get_core_package_dir
|
||||
from platformio.managers.package import BasePkgManager, PackageManager
|
||||
|
||||
|
||||
@ -161,12 +162,14 @@ class PlatformManager(BasePkgManager):
|
||||
def get_registered_boards():
|
||||
return util.get_api_result("/boards", cache_valid="30d")
|
||||
|
||||
def board_config(self, id_):
|
||||
def board_config(self, id_, platform=None):
|
||||
for manifest in self.get_installed_boards():
|
||||
if manifest['id'] == id_:
|
||||
if manifest['id'] == id_ and (not platform or
|
||||
manifest['platform'] == platform):
|
||||
return manifest
|
||||
for manifest in self.get_registered_boards():
|
||||
if manifest['id'] == id_:
|
||||
if manifest['id'] == id_ and (not platform or
|
||||
manifest['platform'] == platform):
|
||||
return manifest
|
||||
raise exception.UnknownBoard(id_)
|
||||
|
||||
@ -334,7 +337,7 @@ class PlatformRunMixin(object):
|
||||
def _run_scons(self, variables, targets):
|
||||
cmd = [
|
||||
util.get_pythonexe_path(),
|
||||
join(self.get_package_dir("tool-scons"), "script", "scons"), "-Q",
|
||||
join(get_core_package_dir("tool-scons"), "script", "scons"), "-Q",
|
||||
"-j %d" % self.get_job_nums(), "--warn=no-no-parallel-support",
|
||||
"-f", join(util.get_source_dir(), "builder", "main.py")
|
||||
]
|
||||
@ -553,17 +556,6 @@ class PlatformBase( # pylint: disable=too-many-public-methods
|
||||
# skip all packages, allow only upload tools
|
||||
self.packages[_name]['optional'] = True
|
||||
|
||||
if "__test" in targets and "tool-unity" not in self.packages:
|
||||
self.packages['tool-unity'] = {
|
||||
"version": "~1.20302.1",
|
||||
"optional": False
|
||||
}
|
||||
if "tool-scons" not in self.packages:
|
||||
self.packages['tool-scons'] = {
|
||||
"version": "~3.20501.2",
|
||||
"optional": False
|
||||
}
|
||||
|
||||
def get_lib_storages(self):
|
||||
storages = []
|
||||
for opts in (self.frameworks or {}).values():
|
||||
|
Reference in New Issue
Block a user