use of com.jetbrains.python.newProject.PyFrameworkProjectGenerator in project intellij-community by JetBrains.
the class ProjectSpecificSettingsStep method checkValid.
@Override
public boolean checkValid() {
myInstallFramework = false;
if (!super.checkValid()) {
return false;
}
if (myProjectGenerator instanceof PythonProjectGenerator) {
final Sdk sdk = getSdk();
if (sdk == null) {
if (!((PythonProjectGenerator) myProjectGenerator).hideInterpreter()) {
setErrorText("No Python interpreter selected");
return false;
}
return true;
}
if (PythonSdkType.isInvalid(sdk)) {
setErrorText("Choose valid python interpreter");
return false;
}
final List<String> warningList = new ArrayList<>();
final boolean isPy3k = PythonSdkType.getLanguageLevelForSdk(sdk).isPy3K();
try {
acceptsSdk(myProjectGenerator, sdk, new File(myLocationField.getText()));
} catch (final PythonProjectGenerator.PyNoProjectAllowedOnSdkException e) {
setErrorText(e.getMessage());
return false;
}
if (myRemotePathRequired && StringUtil.isEmpty(myRemotePathField.getTextField().getText())) {
setErrorText("Remote path not provided");
return false;
}
if (myProjectGenerator instanceof PyFrameworkProjectGenerator) {
PyFrameworkProjectGenerator frameworkProjectGenerator = (PyFrameworkProjectGenerator) myProjectGenerator;
String frameworkName = frameworkProjectGenerator.getFrameworkTitle();
if (!isFrameworkInstalled(sdk)) {
if (PyPackageUtil.packageManagementEnabled(sdk)) {
myInstallFramework = true;
final List<PyPackage> packages = PyPackageUtil.refreshAndGetPackagesModally(sdk);
if (packages == null) {
warningList.add(frameworkName + " will be installed on the selected interpreter");
return false;
}
if (!PyPackageUtil.hasManagement(packages)) {
warningList.add("Python packaging tools and " + frameworkName + " will be installed on the selected interpreter");
} else {
warningList.add(frameworkName + " will be installed on the selected interpreter");
}
} else {
warningList.add(frameworkName + " is not installed on the selected interpreter");
}
}
final ValidationResult warningResult = ((PythonProjectGenerator) myProjectGenerator).warningValidation(sdk);
if (!warningResult.isOk()) {
warningList.add(warningResult.getErrorMessage());
}
if (!warningList.isEmpty()) {
final String warning = StringUtil.join(warningList, "<br/>");
setWarningText(warning);
}
if (isPy3k && !((PyFrameworkProjectGenerator) myProjectGenerator).supportsPython3()) {
setErrorText(frameworkName + " is not supported for the selected interpreter");
return false;
}
}
}
return true;
}
use of com.jetbrains.python.newProject.PyFrameworkProjectGenerator in project intellij-community by JetBrains.
the class ProjectSpecificSettingsStep method createInterpreterCombo.
@NotNull
private LabeledComponent<PythonSdkChooserCombo> createInterpreterCombo() {
final Project project = ProjectManager.getInstance().getDefaultProject();
final List<Sdk> sdks = PyConfigurableInterpreterList.getInstance(project).getAllPythonSdks();
VirtualEnvProjectFilter.removeAllAssociated(sdks);
Sdk compatibleSdk = sdks.isEmpty() ? null : sdks.iterator().next();
DirectoryProjectGenerator generator = getProjectGenerator();
if (generator instanceof PyFrameworkProjectGenerator && !((PyFrameworkProjectGenerator) generator).supportsPython3()) {
if (compatibleSdk != null && PythonSdkType.getLanguageLevelForSdk(compatibleSdk).isPy3K()) {
Sdk python2Sdk = PythonSdkType.findPython2Sdk(sdks);
if (python2Sdk != null) {
compatibleSdk = python2Sdk;
}
}
}
final Sdk preferred = compatibleSdk;
mySdkCombo = new PythonSdkChooserCombo(project, sdks, sdk -> sdk == preferred);
if (SystemInfo.isMac && !UIUtil.isUnderDarcula()) {
mySdkCombo.putClientProperty("JButton.buttonType", null);
}
mySdkCombo.setButtonIcon(PythonIcons.Python.InterpreterGear);
return LabeledComponent.create(mySdkCombo, "Interpreter", BorderLayout.WEST);
}
Aggregations