56
56
if os .path .exists (map_file ):
57
57
os .remove (map_file )
58
58
59
- def install_standard_python_deps ():
60
- def _get_installed_standard_pip_packages ():
61
- result = {}
62
- packages = {}
63
- pip_output = subprocess .check_output (
64
- [
65
- env .subst ("$PYTHONEXE" ),
66
- "-m" ,
67
- "pip" ,
68
- "list" ,
69
- "--format=json" ,
70
- "--disable-pip-version-check" ,
71
- ]
72
- )
73
- try :
74
- packages = json .loads (pip_output )
75
- except :
76
- print ("Warning! Couldn't extract the list of installed Python packages." )
77
- return {}
78
- for p in packages :
79
- result [p ["name" ]] = pepver_to_semver (p ["version" ])
80
-
81
- return result
82
-
83
- deps = {
84
- "wheel" : ">=0.35.1" ,
85
- "rich-click" : ">=1.8.6" ,
86
- "PyYAML" : ">=6.0.2" ,
87
- "intelhex" : ">=2.3.0" ,
88
- "rich" : ">=14.0.0" ,
89
- "esp-idf-size" : ">=1.6.1"
90
- }
91
-
92
- installed_packages = _get_installed_standard_pip_packages ()
93
- packages_to_install = []
94
- for package , spec in deps .items ():
95
- if package not in installed_packages :
96
- packages_to_install .append (package )
97
- else :
98
- version_spec = semantic_version .Spec (spec )
99
- if not version_spec .match (installed_packages [package ]):
100
- packages_to_install .append (package )
101
-
102
- if packages_to_install :
103
- env .Execute (
104
- env .VerboseAction (
105
- (
106
- '"$PYTHONEXE" -m pip install -U -q -q -q '
107
- + " " .join (
108
- [
109
- '"%s%s"' % (p , deps [p ])
110
- for p in packages_to_install
111
- ]
112
- )
113
- ),
114
- "Installing standard Python dependencies" ,
115
- )
116
- )
117
- return
118
-
119
- install_standard_python_deps ()
120
-
121
59
# Allow changes in folders of managed components
122
60
os .environ ["IDF_COMPONENT_OVERWRITE_MANAGED_COMPONENTS" ] = "1"
123
61
@@ -173,7 +111,7 @@ def create_silent_action(action_func):
173
111
os .rename (ARDUINO_FRAMEWORK_DIR , new_path )
174
112
ARDUINO_FRAMEWORK_DIR = new_path
175
113
assert ARDUINO_FRAMEWORK_DIR and os .path .isdir (ARDUINO_FRAMEWORK_DIR )
176
- arduino_libs_mcu = join (platform .get_package_dir ("framework-arduinoespressif32-libs" ),mcu )
114
+ arduino_libs_mcu = join (platform .get_package_dir ("framework-arduinoespressif32-libs" ), mcu )
177
115
178
116
BUILD_DIR = env .subst ("$BUILD_DIR" )
179
117
PROJECT_DIR = env .subst ("$PROJECT_DIR" )
@@ -1548,24 +1486,17 @@ def generate_mbedtls_bundle(sdk_config):
1548
1486
1549
1487
1550
1488
def install_python_deps ():
1551
- def _get_installed_pip_packages (python_exe_path ):
1489
+ def _get_installed_uv_packages (python_exe_path ):
1552
1490
result = {}
1553
- packages = {}
1554
- pip_output = subprocess .check_output (
1555
- [
1556
- python_exe_path ,
1557
- "-m" ,
1558
- "pip" ,
1559
- "list" ,
1560
- "--format=json" ,
1561
- "--disable-pip-version-check" ,
1562
- ]
1563
- )
1564
1491
try :
1565
- packages = json .loads (pip_output )
1566
- except :
1567
- print ("Warning! Couldn't extract the list of installed Python packages." )
1492
+ uv_output = subprocess .check_output ([
1493
+ "uv" , "pip" , "list" , "--python" , python_exe_path , "--format=json"
1494
+ ])
1495
+ packages = json .loads (uv_output )
1496
+ except (subprocess .CalledProcessError , json .JSONDecodeError , OSError ) as e :
1497
+ print (f"Warning! Couldn't extract the list of installed Python packages: { e } " )
1568
1498
return {}
1499
+
1569
1500
for p in packages :
1570
1501
result [p ["name" ]] = pepver_to_semver (p ["version" ])
1571
1502
@@ -1576,7 +1507,7 @@ def _get_installed_pip_packages(python_exe_path):
1576
1507
return
1577
1508
1578
1509
deps = {
1579
- "wheel " : ">=0.35.1 " ,
1510
+ "uv " : ">=0.1.0 " ,
1580
1511
# https://github.com/platformio/platformio-core/issues/4614
1581
1512
"urllib3" : "<2" ,
1582
1513
# https://github.com/platformio/platform-espressif32/issues/635
@@ -1590,7 +1521,7 @@ def _get_installed_pip_packages(python_exe_path):
1590
1521
deps ["chardet" ] = ">=3.0.2,<4"
1591
1522
1592
1523
python_exe_path = get_python_exe ()
1593
- installed_packages = _get_installed_pip_packages (python_exe_path )
1524
+ installed_packages = _get_installed_uv_packages (python_exe_path )
1594
1525
packages_to_install = []
1595
1526
for package , spec in deps .items ():
1596
1527
if package not in installed_packages :
@@ -1601,21 +1532,22 @@ def _get_installed_pip_packages(python_exe_path):
1601
1532
packages_to_install .append (package )
1602
1533
1603
1534
if packages_to_install :
1535
+ packages_str = " " .join (['"%s%s"' % (p , deps [p ]) for p in packages_to_install ])
1536
+
1537
+ # Use uv to install packages in the specific Python environment
1604
1538
env .Execute (
1605
1539
env .VerboseAction (
1606
- (
1607
- '"%s" -m pip install -U -q -q -q ' % python_exe_path
1608
- + " " .join (['"%s%s"' % (p , deps [p ]) for p in packages_to_install ])
1609
- ),
1610
- "Installing ESP-IDF's Python dependencies" ,
1540
+ f'uv pip install --python "{ python_exe_path } " { packages_str } ' ,
1541
+ "Installing ESP-IDF's Python dependencies with uv" ,
1611
1542
)
1612
1543
)
1613
1544
1614
1545
if IS_WINDOWS and "windows-curses" not in installed_packages :
1546
+ # Install windows-curses in the IDF Python environment
1615
1547
env .Execute (
1616
1548
env .VerboseAction (
1617
- '"%s" -m pip install -q -q -q windows-curses' % python_exe_path ,
1618
- "Installing windows-curses package" ,
1549
+ f'uv pip install --python " { python_exe_path } " windows-curses' ,
1550
+ "Installing windows-curses package with uv " ,
1619
1551
)
1620
1552
)
1621
1553
0 commit comments