PY-61669: After review 111111: remove setWorkDir

GitOrigin-RevId: f65548dead397eebb68caf1f67aefd800d50a209
This commit is contained in:
Ilya.Kazakevich
2023-07-17 15:06:00 +02:00
committed by intellij-monorepo-bot
parent b8c2deb3b3
commit a79228c281
2 changed files with 7 additions and 9 deletions

View File

@@ -6,6 +6,7 @@ package com.jetbrains.python.packaging.management
import com.intellij.execution.RunCanceledByUserException
import com.intellij.execution.process.CapturingProcessHandler
import com.intellij.execution.target.TargetProgressIndicator
import com.intellij.execution.target.value.getTargetEnvironmentValueForLocalPath
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.diagnostic.thisLogger
import com.intellij.openapi.progress.EmptyProgressIndicator
@@ -40,7 +41,7 @@ suspend fun PythonPackageManager.runPackagingTool(operation: String, arguments:
// todo[akniazev]: check applyWorkingDir: PyTargetEnvironmentPackageManager.java:133
project.guessProjectDir()?.toNioPath()?.let {
pythonExecution.setWorkDir(it)
pythonExecution.workingDir = getTargetEnvironmentValueForLocalPath(it)
}
pythonExecution.addParameter(operation)
@@ -79,7 +80,7 @@ suspend fun PythonPackageManager.runPackagingTool(operation: String, arguments:
val handler = CapturingProcessHandler(process, targetedCommandLine.charset, commandLineString)
val result = withBackgroundProgress(project, text, cancellable = true) {
handler.runProcess(10 * 60 * 1000)
handler.runProcess(10 * 60 * 1000)
}
if (result.isCancelled) throw RunCanceledByUserException()
@@ -119,7 +120,9 @@ fun PythonPackageManager.isInstalled(name: String): Boolean {
return installedPackages.any { it.name.lowercase() == name.lowercase() }
}
fun PythonRepositoryManager.createSpecification(name: String, version: String? = null, relation: PyRequirementRelation? = null): PythonPackageSpecification {
fun PythonRepositoryManager.createSpecification(name: String,
version: String? = null,
relation: PyRequirementRelation? = null): PythonPackageSpecification {
val repository = packagesByRepository().first { it.second.any { pkg -> pkg.lowercase() == name.lowercase() } }.first
return repository.createPackageSpecification(name, version, relation)
}

View File

@@ -4,12 +4,11 @@ package com.jetbrains.python.run
import com.intellij.execution.target.FullPathOnTarget
import com.intellij.execution.target.value.TargetEnvironmentFunction
import com.intellij.execution.target.value.constant
import com.intellij.execution.target.value.getTargetEnvironmentValueForLocalPath
import com.intellij.openapi.vfs.encoding.EncodingManager
import org.jetbrains.annotations.ApiStatus
import org.jetbrains.annotations.ApiStatus.ScheduledForRemoval
import java.io.File
import java.nio.charset.Charset
import java.nio.file.Path
/**
* Represents the Python script or module to be executed and its parameters.
@@ -30,10 +29,6 @@ sealed class PythonExecution {
var inputFile: File? = null
fun setWorkDir(localPath: Path) {
this.workingDir = getTargetEnvironmentValueForLocalPath(localPath)
}
fun addParameter(value: String) {
addParameter(constant(value))
}