[python] PY-84973 Create venv implicitly for welcome project

(cherry picked from commit 8aeb5f42c73ae3dd93143103d1886cb760f96545)

IJ-MR-179754

GitOrigin-RevId: 741966433990e15eed6e739c33801006e98fc86c
This commit is contained in:
Alexey Katsman
2025-10-24 15:24:13 +00:00
committed by intellij-monorepo-bot
parent b0245713cb
commit 791364c9d1
2 changed files with 11 additions and 3 deletions
@@ -27,6 +27,7 @@ import com.intellij.platform.util.progress.reportRawProgress
import com.intellij.python.community.services.systemPython.SystemPython
import com.intellij.python.community.services.systemPython.SystemPythonService
import com.intellij.python.sdkConfigurator.common.enableSDKAutoConfigurator
import com.intellij.util.PlatformUtils
import com.jetbrains.python.PyBundle
import com.jetbrains.python.getOrLogException
import com.jetbrains.python.packaging.utils.PyPackageCoroutine
@@ -56,10 +57,10 @@ class PythonSdkConfigurator : DirectoryProjectConfigurator {
val sdk = project.pythonSdk
thisLogger().debug { "Input: $sdk" }
/*
* Technically, we can end up in a situation when we created a project, but failed to configure SDK for some reason, which would
* lead to automatic SDK configuration.
* DataSpell skips SDK setup on new project creation, so we need to use auto-detection there. At the same time, with PyCharm we
* first open a project and only then persist SDK from the dialog. So at this step we'll have null SDK for new projects.
*/
if (sdk != null) {
if (sdk != null || (isProjectCreatedWithWizard && !PlatformUtils.isDataSpell())) {
return
}
if (PySdkFromEnvironmentVariable.getPycharmPythonPathProperty()?.isNotBlank() == true) {
@@ -1,12 +1,15 @@
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.pycharm.community.ide.impl.welcomeScreen
import com.intellij.openapi.diagnostic.thisLogger
import com.intellij.openapi.project.Project
import com.intellij.openapi.project.ex.ProjectEx
import com.intellij.openapi.wm.ex.WelcomeScreenProjectProvider
import com.intellij.platform.PlatformProjectOpenProcessor
import com.intellij.pycharm.community.ide.impl.miscProject.impl.MISC_PROJECT_NAME
import com.intellij.pycharm.community.ide.impl.miscProject.impl.MISC_PROJECT_WITH_WELCOME_NAME
import com.intellij.pycharm.community.ide.impl.miscProject.impl.miscProjectDefaultPath
import com.jetbrains.python.projectCreation.createVenvAndSdk
import java.nio.file.Path
private class PyCharmWelcomeScreenProjectProvider : WelcomeScreenProjectProvider() {
@@ -30,6 +33,10 @@ private class PyCharmWelcomeScreenProjectProvider : WelcomeScreenProjectProvider
project.setProjectName(MISC_PROJECT_WITH_WELCOME_NAME)
project.save()
}
if (PlatformProjectOpenProcessor.isNewProject(project)) {
createVenvAndSdk(project)
}
return project
}