From b78b28ea0edec4aea262b9a31958ab3114659ab3 Mon Sep 17 00:00:00 2001 From: Otto Winter Date: Fri, 18 Oct 2019 15:33:30 +0200 Subject: [PATCH] Fix platformio monkey patch (#768) --- esphome/platformio_api.py | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/esphome/platformio_api.py b/esphome/platformio_api.py index a2626c604e..1b79be2526 100644 --- a/esphome/platformio_api.py +++ b/esphome/platformio_api.py @@ -12,27 +12,18 @@ from esphome.util import run_external_command, run_external_process _LOGGER = logging.getLogger(__name__) -def is_platformio4(): - from platformio import VERSION - return VERSION[0] >= 4 - - def patch_structhash(): # Patch platformio's structhash to not recompile the entire project when files are # removed/added. This might have unintended consequences, but this improves compile # times greatly when adding/removing components and a simple clean build solves # all issues - # pylint: disable=no-member,no-name-in-module,import-error - from platformio.commands import run - from platformio import util - if is_platformio4(): - from platformio.project.helpers import get_project_dir - else: - from platformio.util import get_project_dir + from platformio.commands.run import helpers, command from os.path import join, isdir, getmtime from os import makedirs def patched_clean_build_dir(build_dir, *args): + from platformio import util + from platformio.project.helpers import get_project_dir platformio_ini = join(get_project_dir(), "platformio.ini") # if project's config is modified @@ -43,10 +34,8 @@ def patch_structhash(): makedirs(build_dir) # pylint: disable=protected-access - if is_platformio4(): - run.helpers.clean_build_dir = patched_clean_build_dir - else: - run._clean_build_dir = patched_clean_build_dir + helpers.clean_build_dir = patched_clean_build_dir + command.clean_build_dir = patched_clean_build_dir def run_platformio_cli(*args, **kwargs):