diff --git a/python/python-test-env/junit5/BUILD.bazel b/python/python-test-env/junit5/BUILD.bazel index 12835be1fef4..ab74bd9af8b6 100644 --- a/python/python-test-env/junit5/BUILD.bazel +++ b/python/python-test-env/junit5/BUILD.bazel @@ -40,7 +40,10 @@ jvm_library( ], allow_empty = True, ), - module_name = "intellij.python.test.env.junit5", + associates = [ + "//python:python-community-impl", + "//python:python-community-impl_test_lib", + ], resource_strip_prefix = "resources", resources = glob( ["resources/**/*"], @@ -82,8 +85,6 @@ jvm_library( "//python/python-sdk:sdk_test_lib", "//python/junit5Tests-framework:community-junit5Tests-framework", "//python/junit5Tests-framework:community-junit5Tests-framework_test_lib", - "//python:python-community-impl", - "//python:python-community-impl_test_lib", "//platform/execution", "//platform/execution:execution_test_lib", "//python/python-test-env/conda", diff --git a/python/python-test-env/junit5/intellij.python.test.env.junit5.iml b/python/python-test-env/junit5/intellij.python.test.env.junit5.iml index 833c3a7e839b..7434d13df457 100644 --- a/python/python-test-env/junit5/intellij.python.test.env.junit5.iml +++ b/python/python-test-env/junit5/intellij.python.test.env.junit5.iml @@ -34,4 +34,5 @@ + \ No newline at end of file diff --git a/python/src/com/jetbrains/python/hatch/sdk/HatchSdkFlavorAndData.kt b/python/src/com/jetbrains/python/hatch/sdk/HatchSdkFlavorAndData.kt index f7f4467db550..b1676c37167d 100644 --- a/python/src/com/jetbrains/python/hatch/sdk/HatchSdkFlavorAndData.kt +++ b/python/src/com/jetbrains/python/hatch/sdk/HatchSdkFlavorAndData.kt @@ -25,7 +25,7 @@ internal class HatchSdkFlavorProvider : PythonFlavorProvider { override fun getFlavor(): PythonSdkFlavor<*> = HatchSdkFlavor } -class HatchSdkAdditionalData( +internal class HatchSdkAdditionalData( val hatchWorkingDirectory: Path?, val hatchEnvironmentName: String?, ) : PythonSdkAdditionalData(PyFlavorAndData(data = HatchSdkFlavorData, flavor = HatchSdkFlavor)) { diff --git a/python/src/com/jetbrains/python/hatch/sdk/HatchVirtualEnvironmentExt.kt b/python/src/com/jetbrains/python/hatch/sdk/HatchVirtualEnvironmentExt.kt index 7d7ef77bd75e..c116b4cc70ca 100644 --- a/python/src/com/jetbrains/python/hatch/sdk/HatchVirtualEnvironmentExt.kt +++ b/python/src/com/jetbrains/python/hatch/sdk/HatchVirtualEnvironmentExt.kt @@ -16,7 +16,7 @@ import org.jetbrains.annotations.ApiStatus import java.nio.file.Path @ApiStatus.Internal -suspend fun HatchVirtualEnvironment.createSdk(workingDirectoryPath: Path): PyResult { +internal suspend fun HatchVirtualEnvironment.createSdk(workingDirectoryPath: Path): PyResult { if (pythonVirtualEnvironment !is PythonVirtualEnvironment.Existing) { return Result.failure(BasePythonExecutableNotFoundHatchError(null as String?)) } diff --git a/python/src/com/jetbrains/python/sdk/poetry/PoetryCommandExecutor.kt b/python/src/com/jetbrains/python/sdk/poetry/PoetryCommandExecutor.kt index 505b39a443df..21c887b3ee0c 100644 --- a/python/src/com/jetbrains/python/sdk/poetry/PoetryCommandExecutor.kt +++ b/python/src/com/jetbrains/python/sdk/poetry/PoetryCommandExecutor.kt @@ -61,7 +61,7 @@ private val POETRY_TOOL: ToolCommandExecutor = ToolCommandExecutor( private val POETRY_EXCLUDE_NON_DIGITS_REGEX = Regex("""\D+$""") @Internal -suspend fun runPoetry( +internal suspend fun runPoetry( projectPath: Path?, vararg args: String, inProjectEnv: Boolean? = null, @@ -84,14 +84,14 @@ suspend fun runPoetry( * Returns the configured poetry executable or detects it automatically on the given [fileSystem]. */ @Internal -suspend fun

getPoetryExecutable(fileSystem: FileSystem

): P? = +internal suspend fun

getPoetryExecutable(fileSystem: FileSystem

): P? = POETRY_TOOL.getToolExecutable(fileSystem, pathFromSdk = null) /** * Returns the configured poetry executable or detects it automatically. */ @Internal -suspend fun getPoetryExecutable(eel: EelApi = localEel): Path? = +internal suspend fun getPoetryExecutable(eel: EelApi = localEel): Path? = getPoetryExecutable(EelFileSystem(eel))?.path /** @@ -101,7 +101,7 @@ suspend fun getPoetryExecutable(eel: EelApi = localEel): Path? = * 2. `poetry [args]` */ @Internal -suspend fun runPoetryWithSdk(sdk: Sdk, vararg args: String): PyResult { +internal suspend fun runPoetryWithSdk(sdk: Sdk, vararg args: String): PyResult { val projectPath = sdk.associatedModulePath?.let { Path.of(it) } ?: return PyResult.localizedError(poetryNotFoundException) // Choose a correct sdk val pythonHomePath = sdk.pyRichSdkAsync().pythonHomePath @@ -121,7 +121,7 @@ suspend fun runPoetryWithSdk(sdk: Sdk, vararg args: String): PyResult { * @return the path to the poetry environment. */ @Internal -suspend fun setupPoetry( +internal suspend fun setupPoetry( projectPath: Path, basePythonBinaryPath: PythonBinary, installPackages: Boolean, @@ -181,13 +181,13 @@ private suspend fun getPythonExecutable(homePathString: String): PythonBinary? = * @param [extraArgs] Additional arguments to pass to the Poetry add command. */ @Internal -suspend fun poetryInstallPackage(sdk: Sdk, packages: List, extraArgs: List): PyResult { +internal suspend fun poetryInstallPackage(sdk: Sdk, packages: List, extraArgs: List): PyResult { val args = listOf("add") + packages + extraArgs return runPoetryWithSdk(sdk, *args.toTypedArray()) } @Internal -suspend fun poetryInstallPackageDetached(sdk: Sdk, packages: List, extraArgs: List): PyResult { +internal suspend fun poetryInstallPackageDetached(sdk: Sdk, packages: List, extraArgs: List): PyResult { val args = listOf("run", "pip", "install") + packages + extraArgs return runPoetryWithSdk(sdk, *args.toTypedArray()) } @@ -199,7 +199,7 @@ suspend fun poetryInstallPackageDetached(sdk: Sdk, packages: List, extra * @param [packages] The name of the package to be uninstalled. */ @Internal -suspend fun poetryRemovePackage(sdk: Sdk, vararg packages: String): PyResult = runPoetryWithSdk(sdk, "remove", *packages) +internal suspend fun poetryRemovePackage(sdk: Sdk, vararg packages: String): PyResult = runPoetryWithSdk(sdk, "remove", *packages) @Internal suspend fun poetryUninstallPackage(sdk: Sdk, vararg packages: String): PyResult { @@ -208,7 +208,7 @@ suspend fun poetryUninstallPackage(sdk: Sdk, vararg packages: String): PyResult< } @Internal -fun parsePoetryShow(input: String): List { +internal fun parsePoetryShow(input: String): List { val result = mutableListOf() input.split("\n").forEach { line -> if (line.isNotBlank()) { @@ -221,14 +221,14 @@ fun parsePoetryShow(input: String): List { } @Internal -suspend fun poetryShowOutdated(sdk: Sdk): PyResult> { +internal suspend fun poetryShowOutdated(sdk: Sdk): PyResult> { val output = runPoetryWithSdk(sdk, "show", "--all", "--outdated").getOr { return it } return parsePoetryShowOutdated(output).let { PyResult.success(it) } } @Internal -suspend fun poetryListPackages(sdk: Sdk): PyResult, List>> { +internal suspend fun poetryListPackages(sdk: Sdk): PyResult, List>> { val version = getPoetryVersion()?.toVersion() // Ensure that the lock file is up to date. @@ -244,7 +244,7 @@ suspend fun poetryListPackages(sdk: Sdk): PyResult, List { +internal suspend fun fixLock(sdk: Sdk, version: Version?): PyResult { if (version == null || version >= VERSION_2) { return runPoetryWithSdk(sdk, "lock") } @@ -266,7 +266,7 @@ suspend fun fixLock(sdk: Sdk, version: Version?): PyResult { } @Internal -fun parsePoetryInstallDryRun(input: String): Pair, List> { +internal fun parsePoetryInstallDryRun(input: String): Pair, List> { val installedLines = listOf("Already installed", "Skipping", "Updating", "Downgrading") fun getNameAndVersion(line: String): Triple { @@ -313,7 +313,7 @@ fun parsePoetryInstallDryRun(input: String): Pair, List */ -class PoetryPackageManagerProvider : PythonPackageManagerProvider { +internal class PoetryPackageManagerProvider : PythonPackageManagerProvider { override fun createPackageManagerForSdk(project: Project, sdk: Sdk): PythonPackageManager? = if (sdk.isPoetry) PoetryPackageManager(project, sdk) else null } diff --git a/python/src/com/jetbrains/python/sdk/poetry/PyPoetrySdkAdditionalData.kt b/python/src/com/jetbrains/python/sdk/poetry/PyPoetrySdkAdditionalData.kt index 12d5c10ad047..dcfd2804f2cf 100644 --- a/python/src/com/jetbrains/python/sdk/poetry/PyPoetrySdkAdditionalData.kt +++ b/python/src/com/jetbrains/python/sdk/poetry/PyPoetrySdkAdditionalData.kt @@ -9,7 +9,7 @@ import java.nio.file.Path * This source code is edited by @koxudaxi Koudai Aono */ -class PyPoetrySdkAdditionalData : PythonSdkAdditionalData { +internal class PyPoetrySdkAdditionalData : PythonSdkAdditionalData { constructor(associatedModulePath: Path?) : super(PyPoetrySdkFlavor) { this.associatedModulePath = associatedModulePath?.toString() } diff --git a/python/src/com/jetbrains/python/sdk/poetry/PyPoetrySdkFlavor.kt b/python/src/com/jetbrains/python/sdk/poetry/PyPoetrySdkFlavor.kt index e133ca798857..055443ba6e61 100644 --- a/python/src/com/jetbrains/python/sdk/poetry/PyPoetrySdkFlavor.kt +++ b/python/src/com/jetbrains/python/sdk/poetry/PyPoetrySdkFlavor.kt @@ -5,6 +5,7 @@ import com.intellij.python.community.impl.poetry.common.icons.PythonCommunityImp import com.jetbrains.python.sdk.flavors.CPythonSdkFlavor import com.jetbrains.python.sdk.flavors.PyFlavorData import com.jetbrains.python.sdk.flavors.PythonFlavorProvider +import com.jetbrains.python.sdk.flavors.PythonSdkFlavor import java.nio.file.Path import javax.swing.Icon @@ -13,13 +14,13 @@ import javax.swing.Icon * This source code is edited by @koxudaxi Koudai Aono */ -object PyPoetrySdkFlavor : CPythonSdkFlavor() { +internal object PyPoetrySdkFlavor : CPythonSdkFlavor() { override fun getIcon(): Icon = PythonCommunityImplPoetryCommonIcons.Poetry override fun getFlavorDataClass(): Class = PyFlavorData.Empty::class.java override fun isValidSdkPath(pythonBinaryPath: Path): Boolean = false } -class PyPoetrySdkFlavorProvider : PythonFlavorProvider { - override fun getFlavor(): PyPoetrySdkFlavor = PyPoetrySdkFlavor +internal class PyPoetrySdkFlavorProvider : PythonFlavorProvider { + override fun getFlavor(): PythonSdkFlavor<*> = PyPoetrySdkFlavor } \ No newline at end of file diff --git a/python/src/com/jetbrains/python/sdk/poetry/poetry.kt b/python/src/com/jetbrains/python/sdk/poetry/poetry.kt index 01e9f35d0835..e2c9fc5ce392 100644 --- a/python/src/com/jetbrains/python/sdk/poetry/poetry.kt +++ b/python/src/com/jetbrains/python/sdk/poetry/poetry.kt @@ -23,11 +23,11 @@ import kotlin.io.path.pathString @Internal -fun suggestedSdkName(basePath: Path): @NlsSafe String = "Poetry (${PathUtil.getFileName(basePath.pathString)})" +internal fun suggestedSdkName(basePath: Path): @NlsSafe String = "Poetry (${PathUtil.getFileName(basePath.pathString)})" @Internal -suspend fun createNewPoetrySdk( +internal suspend fun createNewPoetrySdk( moduleBasePath: Path, basePythonBinaryPath: PythonBinary, installPackages: Boolean, @@ -43,7 +43,7 @@ suspend fun createNewPoetrySdk( } @Internal -suspend fun createPoetrySdk( +internal suspend fun createPoetrySdk( basePath: Path, pythonBinaryPath: PathHolder.Eel, ): PyResult = withProgressText(PyBundle.message("python.sdk.progress.poetry.configuring")) { @@ -69,7 +69,7 @@ private suspend fun setUpPoetry(moduleBasePath: Path, basePythonBinaryPath: Pyth return PyResult.success(pythonBinaryPath) } -fun parsePoetryShowOutdated(input: String): Map { +internal fun parsePoetryShowOutdated(input: String): Map { return input .lines() .map { it.trim() } diff --git a/python/src/com/jetbrains/python/sdk/uv/Uv.kt b/python/src/com/jetbrains/python/sdk/uv/Uv.kt index ef90890df19f..2bce8d8e1afb 100644 --- a/python/src/com/jetbrains/python/sdk/uv/Uv.kt +++ b/python/src/com/jetbrains/python/sdk/uv/Uv.kt @@ -13,12 +13,12 @@ import org.jetbrains.annotations.ApiStatus import java.nio.file.Path @ApiStatus.Internal -interface UvCli

{ +internal interface UvCli

{ suspend fun runUv(workingDir: Path, venvPath: P?, canChangeTomlOrLock: Boolean, vararg args: String): PyResult } @ApiStatus.Internal -interface UvLowLevel

{ +internal interface UvLowLevel

{ suspend fun initializeEnvironment(init: Boolean, version: Version?, clearExisting: Boolean = false): PyResult

suspend fun listUvPythons(): PyResult> @@ -50,7 +50,7 @@ interface UvLowLevel

{ } @ApiStatus.Internal -sealed class ScriptSyncCheckResult { +internal sealed class ScriptSyncCheckResult { data object Synced : ScriptSyncCheckResult() data object NotSynced : ScriptSyncCheckResult() data object NoInlineMetadata : ScriptSyncCheckResult() diff --git a/python/src/com/jetbrains/python/sdk/uv/UvExt.kt b/python/src/com/jetbrains/python/sdk/uv/UvExt.kt index e5f6decde4d1..367468e5b0ed 100644 --- a/python/src/com/jetbrains/python/sdk/uv/UvExt.kt +++ b/python/src/com/jetbrains/python/sdk/uv/UvExt.kt @@ -156,7 +156,7 @@ private class MyService(val coroutineScope: CoroutineScope) internal suspend fun Sdk.getUvExecutionContext(project: Project? = null): UvExecutionContext<*>? = getUvExecutionContextAsync(service().coroutineScope, project)?.await() -suspend fun setupNewUvSdkAndEnv(uvExecutable: Path, workingDir: Path, version: Version?, errorSink: ErrorSink): PyResult = +internal suspend fun setupNewUvSdkAndEnv(uvExecutable: Path, workingDir: Path, version: Version?, errorSink: ErrorSink): PyResult = setupNewUvSdkAndEnv( uvExecutable = PathHolder.Eel(uvExecutable), workingDir = workingDir, @@ -166,7 +166,7 @@ suspend fun setupNewUvSdkAndEnv(uvExecutable: Path, workingDir: Path, version: V errorSink = errorSink, ) -suspend fun

setupNewUvSdkAndEnv( +internal suspend fun

setupNewUvSdkAndEnv( uvExecutable: P, workingDir: Path, venvPath: P?, @@ -200,7 +200,7 @@ suspend fun

setupNewUvSdkAndEnv( return PyResult.success(sdk) } -suspend fun setupExistingEnvAndSdk( +internal suspend fun setupExistingEnvAndSdk( pythonBinary: PythonBinary, uvPath: Path, envWorkingDir: Path, @@ -214,7 +214,7 @@ suspend fun setupExistingEnvAndSdk( usePip = usePip ) -suspend fun

setupExistingEnvAndSdk( +internal suspend fun

setupExistingEnvAndSdk( pythonBinary: P, uvPath: P, workingDir: Path, diff --git a/python/src/com/jetbrains/python/sdk/uv/UvPackageManager.kt b/python/src/com/jetbrains/python/sdk/uv/UvPackageManager.kt index 4962c75820d4..abaff86e8dbf 100644 --- a/python/src/com/jetbrains/python/sdk/uv/UvPackageManager.kt +++ b/python/src/com/jetbrains/python/sdk/uv/UvPackageManager.kt @@ -311,7 +311,7 @@ internal class UvPackageManager internal constructor(project: Project, sdk: Sdk, } } -class UvPackageManagerProvider : PythonPackageManagerProvider { +internal class UvPackageManagerProvider : PythonPackageManagerProvider { override fun createPackageManagerForSdk(project: Project, sdk: Sdk): PythonPackageManager? { if (!sdk.isUv) { return null diff --git a/python/src/com/jetbrains/python/sdk/uv/UvPyProject.kt b/python/src/com/jetbrains/python/sdk/uv/UvPyProject.kt index f496f083cb4f..8a1eb649e374 100644 --- a/python/src/com/jetbrains/python/sdk/uv/UvPyProject.kt +++ b/python/src/com/jetbrains/python/sdk/uv/UvPyProject.kt @@ -14,17 +14,17 @@ import org.apache.tuweni.toml.TomlTable import org.jetbrains.annotations.ApiStatus @ApiStatus.Internal -sealed class UvPyProjectIssue { +internal sealed class UvPyProjectIssue { data object SafeGetError : UvPyProjectIssue() } @ApiStatus.Internal -data class UvPyProjectTable( +internal data class UvPyProjectTable( val uvDevDependencies: List?, ) @ApiStatus.Internal -data class UvPyProject(val project: UvPyProjectTable?, val issues: List) { +internal data class UvPyProject(val project: UvPyProjectTable?, val issues: List) { fun matchOutdatedPackages( module: Module, pyProject: PyProjectToml, diff --git a/python/src/com/jetbrains/python/sdk/uv/UvSdkFlavorAndData.kt b/python/src/com/jetbrains/python/sdk/uv/UvSdkFlavorAndData.kt index e8f5be0076a0..d8fe2d253dac 100644 --- a/python/src/com/jetbrains/python/sdk/uv/UvSdkFlavorAndData.kt +++ b/python/src/com/jetbrains/python/sdk/uv/UvSdkFlavorAndData.kt @@ -19,7 +19,7 @@ import java.nio.file.Path import javax.swing.Icon import kotlin.io.path.pathString -class UvSdkAdditionalData : PythonSdkAdditionalData { +internal class UvSdkAdditionalData : PythonSdkAdditionalData { internal val flavorData: UvSdkFlavorData constructor(uvWorkingDirectory: Path?, usePip: Boolean?, venvPath: FullPathOnTarget?, uvPath: FullPathOnTarget?) : this(UvSdkFlavorData( diff --git a/python/src/com/jetbrains/python/sdk/uv/UvUtils.kt b/python/src/com/jetbrains/python/sdk/uv/UvUtils.kt index 7c9560ed17e3..d270a985de4c 100644 --- a/python/src/com/jetbrains/python/sdk/uv/UvUtils.kt +++ b/python/src/com/jetbrains/python/sdk/uv/UvUtils.kt @@ -3,5 +3,5 @@ package com.jetbrains.python.sdk.uv import com.intellij.openapi.diagnostic.Logger -val LOGGER: Logger = Logger.getInstance("#com.jetbrains.python.sdk.uv") +internal val LOGGER: Logger = Logger.getInstance("#com.jetbrains.python.sdk.uv") diff --git a/python/src/com/jetbrains/python/sdk/uv/impl/UvCli.kt b/python/src/com/jetbrains/python/sdk/uv/impl/UvCli.kt index c5922d70252f..14c60c01a55b 100644 --- a/python/src/com/jetbrains/python/sdk/uv/impl/UvCli.kt +++ b/python/src/com/jetbrains/python/sdk/uv/impl/UvCli.kt @@ -87,7 +87,7 @@ private class UvCliImpl

(val dispatcher: CoroutineDispatcher, val suspend fun getUvExecutableLocal(eel: EelApi = localEel): Path? = getUvExecutable(EelFileSystem(eel), null)?.path -suspend fun

getUvExecutable(fileSystem: FileSystem

, pathFromSdk: FullPathOnTarget?): P? = +internal suspend fun

getUvExecutable(fileSystem: FileSystem

, pathFromSdk: FullPathOnTarget?): P? = UV_TOOL.getToolExecutable(fileSystem, pathFromSdk) fun setUvExecutableLocal(path: Path) { @@ -98,11 +98,11 @@ suspend fun hasUvExecutableLocal(): Boolean { return getUvExecutableLocal() != null } -suspend fun createUvCliLocal(uv: Path? = null, dispatcher: CoroutineDispatcher = Dispatchers.IO): PyResult> { +internal suspend fun createUvCliLocal(uv: Path? = null, dispatcher: CoroutineDispatcher = Dispatchers.IO): PyResult> { return createUvCli(uv?.let { PathHolder.Eel(it) }, EelFileSystem(localEel), dispatcher) } -suspend fun

createUvCli( +internal suspend fun

createUvCli( uv: P?, fileSystem: FileSystem

, dispatcher: CoroutineDispatcher = Dispatchers.IO, diff --git a/python/src/com/jetbrains/python/sdk/uv/impl/UvLowLevel.kt b/python/src/com/jetbrains/python/sdk/uv/impl/UvLowLevel.kt index b503346fa6a0..63dc37568af6 100644 --- a/python/src/com/jetbrains/python/sdk/uv/impl/UvLowLevel.kt +++ b/python/src/com/jetbrains/python/sdk/uv/impl/UvLowLevel.kt @@ -315,13 +315,13 @@ private class UvLowLevelImpl

( } } -fun createUvLowLevelLocal(cwd: Path, uvCli: UvCli): UvLowLevel = +internal fun createUvLowLevelLocal(cwd: Path, uvCli: UvCli): UvLowLevel = createUvLowLevel(cwd, uvCli, EelFileSystem(localEel), null) -fun

createUvLowLevel(cwd: Path, uvCli: UvCli

, fileSystem: FileSystem

, venvPath: P?): UvLowLevel

= +internal fun

createUvLowLevel(cwd: Path, uvCli: UvCli

, fileSystem: FileSystem

, venvPath: P?): UvLowLevel

= UvLowLevelImpl(cwd, venvPath, uvCli, fileSystem) -suspend fun createUvLowLevelLocal(cwd: Path): PyResult> = +internal suspend fun createUvLowLevelLocal(cwd: Path): PyResult> = createUvCli(null, EelFileSystem(localEel)).mapSuccess { createUvLowLevelLocal(cwd, it) } private fun tryExtractStderr(err: PyError): String? = diff --git a/python/src/com/jetbrains/python/sdk/uv/run/UvRunConfigurationState.kt b/python/src/com/jetbrains/python/sdk/uv/run/UvRunConfigurationState.kt index ac8f1301bca3..a306ae54b2cd 100644 --- a/python/src/com/jetbrains/python/sdk/uv/run/UvRunConfigurationState.kt +++ b/python/src/com/jetbrains/python/sdk/uv/run/UvRunConfigurationState.kt @@ -104,7 +104,7 @@ private suspend fun checkRequiresSync( } @ApiStatus.Internal -suspend fun requiresSync( +internal suspend fun requiresSync( uv: UvLowLevel, options: UvRunConfigurationOptions, logger: Logger,