@@ -21,7 +21,7 @@ import { ESP } from "../../config";
2121import { join } from "path" ;
2222import { copy , pathExists , readFile , writeFile } from "fs-extra" ;
2323import { readParameter , readSerialPort } from "../../idfConfiguration" ;
24- import { startPythonReqsProcess } from "../../utils" ;
24+ import { getEspIdfFromCMake , startPythonReqsProcess } from "../../utils" ;
2525import { runTaskForCommand } from "./testExecution" ;
2626import { buildCommand } from "../../build/buildCmd" ;
2727import { verifyCanFlash } from "../../flash/flashCmd" ;
@@ -48,7 +48,10 @@ export async function configurePyTestUnitApp(
4848 if ( ! doesUnitTestAppExists ) {
4949 const unitTestFiles = await getFileList ( ) ;
5050 const testComponents = await getTestComponents ( unitTestFiles ) ;
51- unitTestAppUri = await copyTestAppProject ( workspaceFolder , testComponents ) ;
51+ unitTestAppUri = await copyTestAppProject (
52+ workspaceFolder ,
53+ testComponents
54+ ) ;
5255 await buildFlashTestApp ( unitTestAppUri , cancelToken ) ;
5356 }
5457 return unitTestAppUri ;
@@ -132,6 +135,16 @@ export async function installPyTestPackages(
132135 cancelToken ?: CancellationToken
133136) {
134137 const idfPath = readParameter ( "idf.espIdfPath" , workspaceFolder ) ;
138+ const containerPath =
139+ process . platform === "win32" ? process . env . USERPROFILE : process . env . HOME ;
140+ const confToolsPath = readParameter (
141+ "idf.toolsPath" ,
142+ workspaceFolder
143+ ) as string ;
144+ const toolsPath =
145+ confToolsPath ||
146+ process . env . IDF_TOOLS_PATH ||
147+ join ( containerPath , ".espressif" ) ;
135148 const pythonBinPath = await getVirtualEnvPythonPath ( workspaceFolder ) ;
136149 let requirementsPath = join (
137150 idfPath ,
@@ -148,9 +161,27 @@ export async function installPyTestPackages(
148161 ) ;
149162 }
150163
164+ const fullEspIdfVersion = await getEspIdfFromCMake ( idfPath ) ;
165+ const majorMinorMatches = fullEspIdfVersion . match ( / ( [ 0 - 9 ] + \. [ 0 - 9 ] + ) .* / ) ;
166+ const espIdfVersion =
167+ majorMinorMatches && majorMinorMatches . length > 0
168+ ? majorMinorMatches [ 1 ]
169+ : "x.x" ;
170+ const constrainsFile = join (
171+ toolsPath ,
172+ `espidf.constraints.v${ espIdfVersion } .txt`
173+ ) ;
174+ const constrainsFileExists = await pathExists ( constrainsFile ) ;
175+ let constraintArg = [ ] ;
176+ if ( constrainsFileExists ) {
177+ constraintArg = [ "--constraint" , constrainsFile ] ;
178+ }
179+
151180 await runTaskForCommand (
152181 workspaceFolder ,
153- `"${ pythonBinPath } " -m pip install --upgrade --no-warn-script-location -r "${ requirementsPath } " --extra-index-url https://dl.espressif.com/pypi` ,
182+ `"${ pythonBinPath } " -m pip install --upgrade ${
183+ constraintArg && constraintArg . length > 0 ? constraintArg . join ( " " ) : ""
184+ } --no-warn-script-location -r "${ requirementsPath } " --extra-index-url https://dl.espressif.com/pypi`,
154185 "Install Pytest" ,
155186 cancelToken
156187 ) ;
0 commit comments