From 93167afaf5eb81526a1192fd70d3390af6c48425 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 21 Aug 2020 22:50:45 -0500 Subject: [PATCH] Update copy_marlin_variant_to_framework.py --- .../scripts/copy_marlin_variant_to_framework.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/buildroot/share/PlatformIO/scripts/copy_marlin_variant_to_framework.py b/buildroot/share/PlatformIO/scripts/copy_marlin_variant_to_framework.py index b66ba27fa6..f7d3f0d03a 100644 --- a/buildroot/share/PlatformIO/scripts/copy_marlin_variant_to_framework.py +++ b/buildroot/share/PlatformIO/scripts/copy_marlin_variant_to_framework.py @@ -1,7 +1,19 @@ import os,shutil from SCons.Script import DefaultEnvironment from platformio import util -from platformio.managers.package import PackageManager +try: + # PIO < 4.4 + from platformio.managers.package import PackageManager +except ImportError: + # PIO >= 4.4 + from platformio.package.meta import PackageSpec as PackageManager + +def parse_pkg_uri(spec): + if PackageManager.__name__ == 'PackageSpec': + return PackageManager(spec).name + else: + name, _, _ = PackageManager.parse_pkg_uri(spec) + return name def copytree(src, dst, symlinks=False, ignore=None): for item in os.listdir(src): @@ -26,7 +38,7 @@ framewords = { if len(platform_packages) == 0: platform_name = framewords[platform.__class__.__name__] else: - platform_name, _, _ = PackageManager.parse_pkg_uri(platform_packages[0]) + platform_name = parse_pkg_uri(platform_packages[0]) FRAMEWORK_DIR = platform.get_package_dir(platform_name) assert os.path.isdir(FRAMEWORK_DIR)