Skip to content

Commit

Permalink
Update arduino.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason2866 authored Jul 12, 2024
1 parent 0031001 commit 2946a4e
Showing 1 changed file with 4 additions and 77 deletions.
81 changes: 4 additions & 77 deletions builder/frameworks/arduino.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,90 +22,17 @@
http://arduino.cc/en/Reference/HomePage
"""

import subprocess
import json
import semantic_version
from os.path import join

from SCons.Script import COMMAND_LINE_TARGETS, DefaultEnvironment, SConscript
from platformio.package.version import pepver_to_semver
from SCons.Script import DefaultEnvironment, SConscript

env = DefaultEnvironment()

extra_flags = ''.join([element.replace("-D", " ") for element in env.BoardConfig().get("build.extra_flags", "")])
build_flags = ''.join([element.replace("-D", " ") for element in env.GetProjectOption("build_flags")])
board = env.BoardConfig()
build_core = board.get("build.core", "").lower()

SConscript("_embed_files.py", exports="env")

if ("CORE32SOLO1" in extra_flags or "FRAMEWORK_ARDUINO_SOLO1" in build_flags) and ("arduino" in env.subst("$PIOFRAMEWORK") and "espidf" not in env.subst("$PIOFRAMEWORK")):
SConscript(
join(DefaultEnvironment().PioPlatform().get_package_dir(
"framework-arduino-solo1"), "tools", "platformio-build.py"))

elif ("CORE32ITEAD" in extra_flags or "FRAMEWORK_ARDUINO_ITEAD" in build_flags) and ("arduino" in env.subst("$PIOFRAMEWORK") and "espidf" not in env.subst("$PIOFRAMEWORK")):
SConscript(
join(DefaultEnvironment().PioPlatform().get_package_dir(
"framework-arduino-ITEAD"), "tools", "platformio-build.py"))

elif "arduino" in env.subst("$PIOFRAMEWORK") and "CORE32SOLO1" not in extra_flags and "FRAMEWORK_ARDUINO_SOLO1" not in build_flags and "CORE32ITEAD" not in extra_flags and "FRAMEWORK_ARDUINO_ITEAD" not in build_flags and "espidf" not in env.subst("$PIOFRAMEWORK"):
if "espidf" not in env.subst("$PIOFRAMEWORK"):
SConscript(
join(DefaultEnvironment().PioPlatform().get_package_dir(
"framework-arduinoespressif32"), "tools", "platformio-build.py"))

def install_python_deps():
def _get_installed_pip_packages():
result = {}
packages = {}
pip_output = subprocess.check_output(
[
env.subst("$PYTHONEXE"),
"-m",
"pip",
"list",
"--format=json",
"--disable-pip-version-check",
]
)
try:
packages = json.loads(pip_output)
except:
print("Warning! Couldn't extract the list of installed Python packages.")
return {}
for p in packages:
result[p["name"]] = pepver_to_semver(p["version"])

return result

deps = {
"wheel": ">=0.35.1",
"zopfli": ">=0.2.2",
"tasmota-metrics": ">=0.4.3"
}

installed_packages = _get_installed_pip_packages()
packages_to_install = []
for package, spec in deps.items():
if package not in installed_packages:
packages_to_install.append(package)
else:
version_spec = semantic_version.Spec(spec)
if not version_spec.match(installed_packages[package]):
packages_to_install.append(package)

if packages_to_install:
env.Execute(
env.VerboseAction(
(
'"$PYTHONEXE" -m pip install -U '
+ " ".join(
[
'"%s%s"' % (p, deps[p])
for p in packages_to_install
]
)
),
"Installing Python dependencies",
)
)

install_python_deps()

0 comments on commit 2946a4e

Please sign in to comment.