Skip to content

Commit 8147243

Browse files
committed
ci: apply ESP-IDF constraints to requirements-dev install
Signed-off-by: Scott Shawcroft <scott@tannewt.org>
1 parent 473ec38 commit 8147243

3 files changed

Lines changed: 59 additions & 3 deletions

File tree

.github/actions/deps/external/action.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,16 @@ runs:
5656
uses: ./.github/actions/deps/python
5757
with:
5858
action: ${{ inputs.action }}
59+
- name: Set ESP-IDF constraints path
60+
if: inputs.port == 'espressif'
61+
run: python3 -u tools/ci_set_idf_constraint.py
62+
shell: bash
63+
5964
- name: Install python dependencies
60-
run: pip install -r requirements-dev.txt
65+
run: |
66+
if [ -n "${IDF_CONSTRAINT_FILE:-}" ] && [ -f "$IDF_CONSTRAINT_FILE" ]; then
67+
pip install -c "$IDF_CONSTRAINT_FILE" -r requirements-dev.txt
68+
else
69+
pip install -r requirements-dev.txt
70+
fi
6171
shell: bash

requirements-dev.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ intelhex
2525
# for building & testing natmods
2626
pyelftools
2727

28-
# newer versions break ESP-IDF now
29-
cryptography<45
28+
cryptography
3029

3130
# for web workflow minify
3231
minify_html

tools/ci_set_idf_constraint.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2026 Adafruit Industries LLC
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
"""Set IDF_CONSTRAINT_FILE for CI.
6+
7+
CI installs requirements-dev.txt for all ports, but on Espressif builds we must
8+
also apply the matching ESP-IDF constraints file so pip does not upgrade shared
9+
packages (for example click) beyond what ESP-IDF allows. This script derives the
10+
active ESP-IDF major.minor version from version.cmake and exports the exact
11+
constraints file path into GITHUB_ENV for later install steps.
12+
"""
13+
14+
import os
15+
import pathlib
16+
import re
17+
18+
TOP = pathlib.Path(__file__).resolve().parent.parent
19+
20+
21+
def main() -> None:
22+
version_cmake = TOP / "ports" / "espressif" / "esp-idf" / "tools" / "cmake" / "version.cmake"
23+
data = version_cmake.read_text(encoding="utf-8")
24+
25+
major = re.search(r"IDF_VERSION_MAJOR\s+(\d+)", data)
26+
minor = re.search(r"IDF_VERSION_MINOR\s+(\d+)", data)
27+
if major is None or minor is None:
28+
raise RuntimeError(f"Unable to parse IDF version from {version_cmake}")
29+
30+
idf_tools_path = os.environ.get("IDF_TOOLS_PATH")
31+
if not idf_tools_path:
32+
raise RuntimeError("IDF_TOOLS_PATH is not set")
33+
34+
constraint = (
35+
pathlib.Path(idf_tools_path) / f"espidf.constraints.v{major.group(1)}.{minor.group(1)}.txt"
36+
)
37+
38+
github_env = os.environ.get("GITHUB_ENV")
39+
if github_env:
40+
with open(github_env, "a", encoding="utf-8") as f:
41+
f.write(f"IDF_CONSTRAINT_FILE={constraint}\n")
42+
43+
print(f"Set IDF_CONSTRAINT_FILE={constraint}")
44+
45+
46+
if __name__ == "__main__":
47+
main()

0 commit comments

Comments
 (0)