Skip to content

Commit a304934

Browse files
committed
adds checking for different esp-idf python versions
1 parent 4764181 commit a304934

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

builder/esp32.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
from . import update_mphalport
88

99

10+
IDF_VER = '5.2.0'
11+
12+
1013
def get_partition_file_name(otp):
1114
if 'Running cmake in directory ' in otp:
1215
build_path = otp.split('Running cmake in directory ', 1)[-1]
@@ -128,7 +131,7 @@ def get_espidf():
128131
]
129132
]
130133
print()
131-
print('collecting ESP-IDF v5.2.0')
134+
print(f'collecting ESP-IDF v{IDF_VER}')
132135
print('this might take a while...')
133136
result, _ = spawn(cmd, spinner=True)
134137
if result != 0:
@@ -466,7 +469,9 @@ def has_correct_idf():
466469
if version:
467470
cached_idf_version = version
468471

469-
return cached_idf_version is not None and cached_idf_version == '5.2.0'
472+
return (
473+
cached_idf_version is not None and cached_idf_version == IDF_VER
474+
)
470475

471476

472477
def build_manifest(
@@ -587,7 +592,9 @@ def setup_idf_environ():
587592

588593
args = " ".join(args)
589594

590-
sys.stderr.write('ESP-IDF version 5.2.0 is needed to compile\n')
595+
sys.stderr.write(
596+
f'ESP-IDF version {IDF_VER} is needed to compile\n'
597+
)
591598
sys.stderr.write(
592599
'Please rerun the build using the command below...\n'
593600
)
@@ -663,7 +670,7 @@ def submodules():
663670
['./install.sh', 'all']
664671
]
665672

666-
print('setting up ESP-IDF v5.2.0')
673+
print(f'setting up ESP-IDF v{IDF_VER}')
667674
print('this might take a while...')
668675
env = {k: v for k, v in os.environ.items()}
669676
env['IDF_PATH'] = os.path.abspath(idf_path)
@@ -928,7 +935,18 @@ def compile(): # NOQA
928935
output = output.rsplit('To flash, run:')[-1].strip()
929936

930937
espressif_path = os.path.expanduser('~/.espressif')
931-
python_path = f'{espressif_path}/python_env/idf5.2_py3.10_env/bin'
938+
939+
for ver in ('3.8', '3.9', '3.10', '3.11', '3.12'):
940+
python_path = (
941+
f'{espressif_path}/python_env/idf{IDF_VER[:-2]}_py{ver}_env/bin'
942+
)
943+
if os.path.exists(python_path):
944+
break
945+
else:
946+
raise RuntimeError(
947+
'unable to locate pyton version used in the ESP-IDF'
948+
)
949+
932950
python_path += '/python'
933951

934952
output = output.split('python ', 1)[-1]

0 commit comments

Comments
 (0)