diff --git a/python/ide/impl/src/com/intellij/pycharm/community/ide/impl/PythonSdkConfigurator.kt b/python/ide/impl/src/com/intellij/pycharm/community/ide/impl/PythonSdkConfigurator.kt index c44516533700..903a525b4144 100644 --- a/python/ide/impl/src/com/intellij/pycharm/community/ide/impl/PythonSdkConfigurator.kt +++ b/python/ide/impl/src/com/intellij/pycharm/community/ide/impl/PythonSdkConfigurator.kt @@ -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) { diff --git a/python/ide/impl/src/com/intellij/pycharm/community/ide/impl/welcomeScreen/PyCharmWelcomeScreenProjectProvider.kt b/python/ide/impl/src/com/intellij/pycharm/community/ide/impl/welcomeScreen/PyCharmWelcomeScreenProjectProvider.kt index 85b288718e4a..9ec35e802dfc 100644 --- a/python/ide/impl/src/com/intellij/pycharm/community/ide/impl/welcomeScreen/PyCharmWelcomeScreenProjectProvider.kt +++ b/python/ide/impl/src/com/intellij/pycharm/community/ide/impl/welcomeScreen/PyCharmWelcomeScreenProjectProvider.kt @@ -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 }