当前位置: 首页>>代码示例>>Java>>正文


Java PythonSdkType.getPythonExecutable方法代码示例

本文整理汇总了Java中com.jetbrains.python.sdk.PythonSdkType.getPythonExecutable方法的典型用法代码示例。如果您正苦于以下问题:Java PythonSdkType.getPythonExecutable方法的具体用法?Java PythonSdkType.getPythonExecutable怎么用?Java PythonSdkType.getPythonExecutable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.jetbrains.python.sdk.PythonSdkType的用法示例。


在下文中一共展示了PythonSdkType.getPythonExecutable方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createVirtualEnv

import com.jetbrains.python.sdk.PythonSdkType; //导入方法依赖的package包/类
@NotNull
public static String createVirtualEnv(@NotNull String destinationDir, String version) throws ExecutionException {
  final String condaExecutable = PyCondaPackageService.getCondaExecutable();
  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,
                                                          "python=" + version, "-y");

  final GeneralCommandLine commandLine = new GeneralCommandLine(parameters);
  final Process process = commandLine.createProcess();
  final CapturingProcessHandler handler = new CapturingProcessHandler(process);
  final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
  final ProcessOutput result = handler.runProcessWithProgressIndicator(indicator);
  if (result.isCancelled()) {
    throw new RunCanceledByUserException();
  }
  final int exitCode = result.getExitCode();
  if (exitCode != 0) {
    final String message = StringUtil.isEmptyOrSpaces(result.getStdout()) && StringUtil.isEmptyOrSpaces(result.getStderr()) ?
                           "Permission denied" : "Non-zero exit code";
    throw new PyExecutionException(message, "Conda", parameters, result);
  }
  final String binary = PythonSdkType.getPythonExecutable(destinationDir);
  final String binaryFallback = destinationDir + File.separator + "bin" + File.separator + "python";
  return (binary != null) ? binary : binaryFallback;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:PyCondaPackageManagerImpl.java

示例2: createVirtualEnv

import com.jetbrains.python.sdk.PythonSdkType; //导入方法依赖的package包/类
@NotNull
public String createVirtualEnv(@NotNull String destinationDir, boolean useGlobalSite) throws ExecutionException {
  final List<String> args = new ArrayList<String>();
  final LanguageLevel languageLevel = PythonSdkType.getLanguageLevelForSdk(mySdk);
  final boolean usePyVenv = languageLevel.isAtLeast(LanguageLevel.PYTHON33);
  if (usePyVenv) {
    args.add("pyvenv");
    if (useGlobalSite) {
      args.add("--system-site-packages");
    }
    args.add(destinationDir);
    getHelperResult(PACKAGING_TOOL, args, false, true, null);
  }
  else {
    if (useGlobalSite) {
      args.add("--system-site-packages");
    }
    args.add(destinationDir);
    final boolean pre26 = languageLevel.isOlderThan(LanguageLevel.PYTHON26);
    final String name = "virtualenv-" + (pre26 ? VIRTUALENV_PRE_26_VERSION : VIRTUALENV_VERSION);
    final String dirName = extractHelper(name + ".tar.gz");
    try {
      final String fileName = dirName + name + File.separatorChar + "virtualenv.py";
      getPythonProcessResult(fileName, args, false, true, dirName + name);
    }
    finally {
      FileUtil.delete(new File(dirName));
    }
  }

  final String binary = PythonSdkType.getPythonExecutable(destinationDir);
  final String binaryFallback = destinationDir + File.separator + "bin" + File.separator + "python";
  final String path = (binary != null) ? binary : binaryFallback;

  if (usePyVenv) {
    // Still no 'packaging' and 'pysetup3' for Python 3.3rc1, see PEP 405
    final VirtualFile binaryFile = LocalFileSystem.getInstance().refreshAndFindFileByPath(path);
    if (binaryFile != null) {
      final ProjectJdkImpl tmpSdk = new ProjectJdkImpl("", PythonSdkType.getInstance());
      tmpSdk.setHomePath(path);
      final PyPackageManager manager = PyPackageManager.getInstance(tmpSdk);
      manager.installManagement();
    }
  }
  return path;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:47,代码来源:PyPackageManagerImpl.java

示例3: getExecutable

import com.jetbrains.python.sdk.PythonSdkType; //导入方法依赖的package包/类
protected String getExecutable(String root, PyTestTask testTask) {
  return PythonSdkType.getPythonExecutable(root);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:PyEnvTaskRunner.java


注:本文中的com.jetbrains.python.sdk.PythonSdkType.getPythonExecutable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。