mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Increase number of correct env activation (PY-34267)
This commit is contained in:
@@ -67,7 +67,7 @@ public class GenerateBinaryStubsFix implements LocalQuickFix {
|
||||
|
||||
/**
|
||||
* Generates pack of fixes available for some unresolved import statement.
|
||||
* Be sure to call {@link #isApplicable(com.jetbrains.python.psi.PyImportStatementBase)} first to make sure this statement is supported
|
||||
* Be sure to call {@link #isApplicable(PyImportStatementBase)} first to make sure this statement is supported
|
||||
*
|
||||
* @param importStatementBase statement to fix
|
||||
* @return pack of fixes
|
||||
@@ -90,7 +90,7 @@ public class GenerateBinaryStubsFix implements LocalQuickFix {
|
||||
|
||||
/**
|
||||
* @param importStatementBase statement to fix
|
||||
* @param qualifiedName name should be fixed (one of {@link com.jetbrains.python.psi.PyImportStatementBase#getFullyQualifiedObjectNames()})
|
||||
* @param qualifiedName name should be fixed (one of {@link PyImportStatementBase#getFullyQualifiedObjectNames()})
|
||||
*/
|
||||
private GenerateBinaryStubsFix(@NotNull final PyImportStatementBase importStatementBase, @NotNull final String qualifiedName) {
|
||||
myQualifiedName = qualifiedName;
|
||||
@@ -175,7 +175,7 @@ public class GenerateBinaryStubsFix implements LocalQuickFix {
|
||||
GeneralCommandLine cmd = PythonHelper.EXTRA_SYSPATH.newCommandLine(homePath, Lists.newArrayList(myQualifiedName));
|
||||
final ProcessOutput runResult = PySdkUtil.getProcessOutput(cmd,
|
||||
new File(homePath).getParent(),
|
||||
PythonSdkType.getVirtualEnvExtraEnv(homePath), 5000
|
||||
PythonSdkType.activateVirtualEnv(homePath), 5000
|
||||
);
|
||||
if (runResult.getExitCode() == 0 && !runResult.isTimeout()) {
|
||||
final String extraPath = runResult.getStdout();
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.jetbrains.python.sdk;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.intellij.execution.ExecutionException;
|
||||
import com.intellij.execution.configurations.GeneralCommandLine;
|
||||
@@ -571,7 +570,7 @@ public final class PythonSdkType extends SdkType {
|
||||
// directory of the script itself - otherwise the dir in which we run the script (e.g. /usr/bin) will be added to SDK path
|
||||
GeneralCommandLine cmd = PythonHelper.SYSPATH.newCommandLine(binaryPath, Lists.newArrayList());
|
||||
final ProcessOutput runResult = PySdkUtil.getProcessOutput(cmd, new File(binaryPath).getParent(),
|
||||
getVirtualEnvExtraEnv(binaryPath), MINUTE);
|
||||
activateVirtualEnv(binaryPath), MINUTE);
|
||||
if (!runResult.checkSuccess(LOG)) {
|
||||
throw new InvalidSdkException(String.format("Failed to determine Python's sys.path value:\nSTDOUT: %s\nSTDERR: %s",
|
||||
runResult.getStdout(),
|
||||
@@ -580,18 +579,6 @@ public final class PythonSdkType extends SdkType {
|
||||
return runResult.getStdoutLines();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a piece of env good as additional env for getProcessOutput.
|
||||
*/
|
||||
@Nullable
|
||||
public static Map<String, String> getVirtualEnvExtraEnv(@NotNull String binaryPath) {
|
||||
final File root = getVirtualEnvRoot(binaryPath);
|
||||
if (root != null) {
|
||||
return ImmutableMap.of("PATH", root.toString());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getVersionString(@NotNull Sdk sdk) {
|
||||
|
||||
@@ -151,8 +151,8 @@ public class PySkeletonGenerator {
|
||||
final String parent_dir = new File(binaryPath).getParent();
|
||||
List<String> commandLine = buildSkeletonGeneratorCommandLine(modname, modfilename, assemblyRefs, binaryPath, extraSyspath);
|
||||
|
||||
final Map<String, String> extraEnv = PythonSdkType.getVirtualEnvExtraEnv(binaryPath);
|
||||
final Map<String, String> env = new HashMap<>(extraEnv != null ? PySdkUtil.mergeEnvVariables(myEnv, extraEnv) : myEnv);
|
||||
final Map<String, String> extraEnv = PythonSdkType.activateVirtualEnv(binaryPath);
|
||||
final Map<String, String> env = new HashMap<>(!extraEnv.isEmpty() ? PySdkUtil.mergeEnvVariables(myEnv, extraEnv) : myEnv);
|
||||
|
||||
if (myPrebuilt) {
|
||||
env.put("IS_PREGENERATED_SKELETONS", "1");
|
||||
@@ -212,7 +212,7 @@ public class PySkeletonGenerator {
|
||||
"-d", mySkeletonsPath, // output dir
|
||||
"-b", // for builtins
|
||||
},
|
||||
PythonSdkType.getVirtualEnvExtraEnv(binaryPath), MINUTE * 5
|
||||
PythonSdkType.activateVirtualEnv(binaryPath), MINUTE * 5
|
||||
);
|
||||
runResult.checkSuccess(LOG);
|
||||
LOG.info("Rebuilding builtin skeletons took " + (System.currentTimeMillis() - startTime) + " ms");
|
||||
@@ -233,7 +233,7 @@ public class PySkeletonGenerator {
|
||||
|
||||
final ProcessOutput process = getProcessOutput(parentDir,
|
||||
ArrayUtil.toStringArray(cmd),
|
||||
PythonSdkType.getVirtualEnvExtraEnv(homePath),
|
||||
PythonSdkType.activateVirtualEnv(homePath),
|
||||
MINUTE * 4); // see PY-3898
|
||||
|
||||
LOG.info("Retrieving binary module list took " + (System.currentTimeMillis() - startTime) + " ms");
|
||||
|
||||
Reference in New Issue
Block a user