Skip to content

Commit 667197c

Browse files
committed
IEP-1529: Fix for system python executable (#1239)
* IEP-1552: Fix for system python executable
1 parent f9ad8a7 commit 667197c

File tree

2 files changed

+9
-60
lines changed

2 files changed

+9
-60
lines changed

bundles/com.espressif.idf.core/src/com/espressif/idf/core/tools/SetupToolsInIde.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ private IStatus handleWebSocketClientInstall()
231231
String websocketClient = "websocket-client"; //$NON-NLS-1$
232232
// pip install websocket-client
233233
List<String> arguments = new ArrayList<String>();
234-
final String pythonEnvPath = IDFUtil.getIDFPythonEnvPath(envVarsFromActivationScriptMap.get(IDFEnvironmentVariables.IDF_PYTHON_ENV_PATH));
234+
final String pythonEnvPath = idfInstalled.getPython();
235235
if (pythonEnvPath == null || !new File(pythonEnvPath).exists())
236236
{
237237
log(String.format("%s executable not found. Unable to run `%s -m pip install websocket-client`", //$NON-NLS-1$
@@ -331,10 +331,8 @@ private IStatus loadTargetsAvailableFromIdfInCurrentToolSet(boolean rollback)
331331
{
332332
List<String> arguments = new ArrayList<String>();
333333
arguments.add(rollback
334-
? IDFUtil.getIDFPythonEnvPath(
335-
existingEnvVarsInIdeForRollback.get(IDFEnvironmentVariables.IDF_PYTHON_ENV_PATH))
336-
: IDFUtil.getIDFPythonEnvPath(
337-
envVarsFromActivationScriptMap.get(IDFEnvironmentVariables.IDF_PYTHON_ENV_PATH)));
334+
? existingEnvVarsInIdeForRollback.get(IDFEnvironmentVariables.PYTHON_EXE_PATH)
335+
: idfInstalled.getPython());
338336
arguments
339337
.add(IDFUtil
340338
.getIDFPythonScriptFile(
@@ -479,6 +477,8 @@ private void setupEnvVarsInEclipse()
479477
idfEnvironmentVariables.addEnvVariable(IDFEnvironmentVariables.IDF_MAINTAINER, "1"); //$NON-NLS-1$
480478
idfEnvironmentVariables.addEnvVariable(IDFEnvironmentVariables.ESP_IDF_EIM_ID, idfInstalled.getId());
481479

480+
idfEnvironmentVariables.addEnvVariable(IDFEnvironmentVariables.PYTHON_EXE_PATH, idfInstalled.getPython());
481+
482482
IDFUtil.updateEspressifPrefPageOpenocdPath();
483483
}
484484

bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/IDFUtil.java

Lines changed: 4 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -187,50 +187,8 @@ public static String getIDFPath()
187187
*/
188188
public static String getIDFPythonEnvPath()
189189
{
190-
String idfPyEnvPath = new IDFEnvironmentVariables().getEnvValue(IDFEnvironmentVariables.IDF_PYTHON_ENV_PATH);
191-
idfPyEnvPath = idfPyEnvPath.strip();
192-
if (!StringUtil.isEmpty(idfPyEnvPath))
193-
{
194-
195-
if (Platform.getOS().equals(Platform.OS_WIN32))
196-
{
197-
idfPyEnvPath = idfPyEnvPath + "/" + "Scripts"; //$NON-NLS-1$ //$NON-NLS-2$
198-
}
199-
else
200-
{
201-
idfPyEnvPath = idfPyEnvPath + "/" + "bin"; //$NON-NLS-1$ //$NON-NLS-2$
202-
}
203-
java.nio.file.Path commandPath = findCommand(IDFConstants.PYTHON_CMD, idfPyEnvPath);
204-
if (commandPath != null)
205-
{
206-
return commandPath.toFile().getAbsolutePath();
207-
}
208-
}
209-
return findCommandFromBuildEnvPath(IDFConstants.PYTHON_CMD);
210-
211-
}
212-
213-
public static String getIDFPythonEnvPath(String idfPyEnvPath)
214-
{
215-
idfPyEnvPath = idfPyEnvPath.strip();
216-
if (!StringUtil.isEmpty(idfPyEnvPath))
217-
{
218-
219-
if (Platform.getOS().equals(Platform.OS_WIN32))
220-
{
221-
idfPyEnvPath = idfPyEnvPath + "/" + "Scripts"; //$NON-NLS-1$ //$NON-NLS-2$
222-
}
223-
else
224-
{
225-
idfPyEnvPath = idfPyEnvPath + "/" + "bin"; //$NON-NLS-1$ //$NON-NLS-2$
226-
}
227-
java.nio.file.Path commandPath = findCommand(IDFConstants.PYTHON_CMD, idfPyEnvPath);
228-
if (commandPath != null)
229-
{
230-
return commandPath.toFile().getAbsolutePath();
231-
}
232-
}
233-
return findCommandFromBuildEnvPath(IDFConstants.PYTHON_CMD);
190+
IDFEnvironmentVariables idfEnvironmentVariables = new IDFEnvironmentVariables();
191+
return idfEnvironmentVariables.getEnvValue(IDFEnvironmentVariables.PYTHON_EXE_PATH);
234192

235193
}
236194

@@ -250,17 +208,8 @@ public static boolean checkIfIdfSupportsSpaces()
250208

251209
public static String getPythonExecutable()
252210
{
253-
IPath pythonPath = new SystemExecutableFinder().find(IDFConstants.PYTHON3_CMD); // look for python3
254-
if (pythonPath == null)
255-
{
256-
pythonPath = new SystemExecutableFinder().find(IDFConstants.PYTHON_CMD); // look for python
257-
}
258-
if (pythonPath != null)
259-
{
260-
return pythonPath.toOSString();
261-
}
262-
263-
return IDFConstants.PYTHON_CMD;
211+
IDFEnvironmentVariables idfEnvironmentVariables = new IDFEnvironmentVariables();
212+
return idfEnvironmentVariables.getEnvValue(IDFEnvironmentVariables.PYTHON_EXE_PATH);
264213
}
265214

266215
/**

0 commit comments

Comments
 (0)