mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fixed PY-17586 Conda: No repositories for installing packages
This commit is contained in:
@@ -74,7 +74,7 @@ public class PyCondaPackageManagerImpl extends PyPackageManagerImpl {
|
||||
}
|
||||
|
||||
private ProcessOutput getCondaOutput(@NotNull final String command, List<String> arguments) throws ExecutionException {
|
||||
final String condaExecutable = PyCondaPackageService.getCondaExecutable();
|
||||
final String condaExecutable = PyCondaPackageService.getCondaExecutable(mySdk.getHomeDirectory());
|
||||
if (condaExecutable == null) throw new PyExecutionException("Cannot find conda", "Conda", Collections.<String>emptyList(), new ProcessOutput());
|
||||
|
||||
final String path = getCondaDirectory();
|
||||
@@ -166,14 +166,14 @@ public class PyCondaPackageManagerImpl extends PyPackageManagerImpl {
|
||||
final String condaName = "conda-meta";
|
||||
final VirtualFile homeDirectory = sdk.getHomeDirectory();
|
||||
if (homeDirectory == null) return false;
|
||||
final VirtualFile condaExecutable = SystemInfo.isWindows ? homeDirectory.getParent().findChild(condaName) :
|
||||
final VirtualFile condaMeta = SystemInfo.isWindows ? homeDirectory.getParent().findChild(condaName) :
|
||||
homeDirectory.getParent().getParent().findChild(condaName);
|
||||
return condaExecutable != null;
|
||||
return condaMeta != null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String createVirtualEnv(@NotNull String destinationDir, String version) throws ExecutionException {
|
||||
final String condaExecutable = PyCondaPackageService.getCondaExecutable();
|
||||
final String condaExecutable = PyCondaPackageService.getSystemCondaExecutable();
|
||||
if (condaExecutable == null) throw new PyExecutionException("Cannot find conda", "Conda", Collections.<String>emptyList(), new ProcessOutput());
|
||||
|
||||
final ArrayList<String> parameters = Lists.newArrayList(condaExecutable, "create", "-p", destinationDir,
|
||||
|
||||
@@ -92,7 +92,7 @@ public class PyCondaPackageService implements PersistentStateComponent<PyCondaPa
|
||||
|
||||
@Nullable
|
||||
public static String getCondaPython() {
|
||||
final String conda = getCondaExecutable();
|
||||
final String conda = getSystemCondaExecutable();
|
||||
final String pythonName = SystemInfo.isWindows ? "python.exe" : "python";
|
||||
if (conda != null) {
|
||||
final VirtualFile condaFile = LocalFileSystem.getInstance().findFileByPath(conda);
|
||||
@@ -108,13 +108,22 @@ public class PyCondaPackageService implements PersistentStateComponent<PyCondaPa
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String getCondaExecutable() {
|
||||
public static String getSystemCondaExecutable() {
|
||||
final String condaName = SystemInfo.isWindows ? "conda.exe" : "conda";
|
||||
final File condaInPath = PathEnvironmentVariableUtil.findInPath(condaName);
|
||||
if (condaInPath != null) return condaInPath.getPath();
|
||||
return getCondaExecutable(condaName);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String getCondaExecutable(VirtualFile sdkPath) {
|
||||
final VirtualFile bin = sdkPath.getParent();
|
||||
final String condaName = SystemInfo.isWindows ? "conda.exe" : "conda";
|
||||
final VirtualFile conda = bin.findChild(condaName);
|
||||
if (conda != null) return conda.getPath();
|
||||
return getSystemCondaExecutable();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String getCondaExecutable(@NotNull final String condaName) {
|
||||
final VirtualFile userHome = LocalFileSystem.getInstance().findFileByPath(SystemProperties.getUserHome().replace('\\', '/'));
|
||||
|
||||
@@ -39,7 +39,7 @@ public class PyPackageManagersImpl extends PyPackageManagers {
|
||||
if (PythonSdkType.isRemote(sdk)) {
|
||||
manager = new PyRemotePackageManagerImpl(sdk);
|
||||
}
|
||||
else if (PyCondaPackageManagerImpl.isCondaVEnv(sdk) && PyCondaPackageService.getCondaExecutable() != null) {
|
||||
else if (PyCondaPackageManagerImpl.isCondaVEnv(sdk) && PyCondaPackageService.getCondaExecutable(sdk.getHomeDirectory()) != null) {
|
||||
manager = new PyCondaPackageManagerImpl(sdk);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -67,7 +67,7 @@ public class PyCondaManagementService extends PyPackageManagementService {
|
||||
|
||||
@Override
|
||||
public void addRepository(String repositoryUrl) {
|
||||
final String conda = PyCondaPackageService.getCondaExecutable();
|
||||
final String conda = PyCondaPackageService.getCondaExecutable(mySdk.getHomeDirectory());
|
||||
final ArrayList<String> parameters = Lists.newArrayList(conda, "config", "--add", "channels", repositoryUrl, "--force");
|
||||
final GeneralCommandLine commandLine = new GeneralCommandLine(parameters);
|
||||
|
||||
@@ -91,7 +91,7 @@ public class PyCondaManagementService extends PyPackageManagementService {
|
||||
|
||||
@Override
|
||||
public void removeRepository(String repositoryUrl) {
|
||||
final String conda = PyCondaPackageService.getCondaExecutable();
|
||||
final String conda = PyCondaPackageService.getCondaExecutable(mySdk.getHomeDirectory());
|
||||
final ArrayList<String> parameters = Lists.newArrayList(conda, "config", "--remove", "channels", repositoryUrl, "--force");
|
||||
final GeneralCommandLine commandLine = new GeneralCommandLine(parameters);
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ public class PyPackageManagementService extends PackageManagementService {
|
||||
@NotNull private static final Pattern PATTERN_ERROR_LINE = Pattern.compile(".*error:.*", Pattern.CASE_INSENSITIVE);
|
||||
|
||||
private final Project myProject;
|
||||
private final Sdk mySdk;
|
||||
protected final Sdk mySdk;
|
||||
|
||||
public PyPackageManagementService(@NotNull final Project project, @NotNull final Sdk sdk) {
|
||||
myProject = project;
|
||||
|
||||
@@ -68,7 +68,7 @@ public class CreateCondaEnvDialog extends AbstractCreateVirtualEnvDialog {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
final String conda = PyCondaPackageService.getCondaExecutable();
|
||||
final String conda = PyCondaPackageService.getSystemCondaExecutable();
|
||||
if (conda != null) {
|
||||
final VirtualFile condaFile = LocalFileSystem.getInstance().findFileByPath(conda);
|
||||
if (condaFile != null) {
|
||||
|
||||
@@ -106,7 +106,7 @@ public class PythonSdkDetailsStep extends BaseListPopupStep<String> {
|
||||
options.add(REMOTE);
|
||||
}
|
||||
options.add(VIRTUALENV);
|
||||
if (PyCondaPackageService.getCondaExecutable() != null) {
|
||||
if (PyCondaPackageService.getSystemCondaExecutable() != null) {
|
||||
options.add(CONDA);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user