🔨 Install 'heatshrink' if needed (#25896)

This commit is contained in:
Scott Lahteine 2023-05-29 19:00:09 -05:00 committed by GitHub
parent d926d4dea4
commit 47616c7dfa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 23 deletions

View file

@ -7,17 +7,6 @@ import serial
Import("env")
# Needed (only) for compression, but there are problems with pip install heatshrink
#try:
# import heatshrink
#except ImportError:
# # Install heatshrink
# print("Installing 'heatshrink' python module...")
# env.Execute(env.subst("$PYTHONEXE -m pip install heatshrink"))
#
# Not tested: If it's safe to install python libraries in PIO python try:
# env.Execute(env.subst("$PYTHONEXE -m pip install https://github.com/p3p/pyheatshrink/releases/download/0.3.3/pyheatshrink-pip.zip"))
import MarlinBinaryProtocol
#-----------------#
@ -191,6 +180,21 @@ def Upload(source, target, env):
# "upload_random_name": generate a random 8.3 firmware filename to upload
upload_random_filename = upload_delete_old_bins and not marlin_long_filename_host_support
# Heatshrink module is needed (only) for compression
if upload_compression:
if sys.version_info[0] > 2:
try:
import heatshrink2
except ImportError:
print("Installing 'heatshrink2' python module...")
env.Execute(env.subst("$PYTHONEXE -m pip install heatshrink2"))
else:
try:
import heatshrink
except ImportError:
print("Installing 'heatshrink' python module...")
env.Execute(env.subst("$PYTHONEXE -m pip install heatshrink"))
try:
# Start upload job