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