-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
basic support for uv env & package manager; PY-75983
GitOrigin-RevId: 2597e4de17e167d8a0b0038190b5127a9dc4b155
- Loading branch information
1 parent
6de9588
commit 9b76b13
Showing
26 changed files
with
976 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
python/pluginResources/inspectionDescriptions/UvPackageVersionsInspection.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<html> | ||
<body> | ||
<p>Reports outdated versions of packages in <code>[dependencies]</code> and <code>[dev-dependencies]</code> | ||
sections of <code>pyproject.toml</code>. | ||
</p> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
python/src/com/jetbrains/python/sdk/add/v2/EnvironmentCreatorUv.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. | ||
package com.jetbrains.python.sdk.add.v2 | ||
|
||
import com.intellij.ide.util.PropertiesComponent | ||
import com.intellij.openapi.module.Module | ||
import com.intellij.openapi.observable.properties.ObservableMutableProperty | ||
import com.intellij.openapi.project.Project | ||
import com.intellij.openapi.projectRoots.Sdk | ||
import com.jetbrains.python.sdk.ModuleOrProject | ||
import com.jetbrains.python.sdk.uv.uvPath | ||
import com.jetbrains.python.sdk.uv.setupUvSdkUnderProgress | ||
import com.jetbrains.python.statistics.InterpreterType | ||
import java.nio.file.Path | ||
|
||
class EnvironmentCreatorUv(model: PythonMutableTargetAddInterpreterModel, private val moduleOrProject: ModuleOrProject?) : CustomNewEnvironmentCreator("uv", model) { | ||
override val interpreterType: InterpreterType = InterpreterType.UV | ||
override val executable: ObservableMutableProperty<String> = model.state.uvExecutable | ||
// FIXME: support uv installation | ||
override val installationScript = null | ||
|
||
override fun onShown() { | ||
// FIXME: validate base interpreters against pyprojecttoml version. See poetry | ||
basePythonComboBox.setItems(model.baseInterpreters) | ||
} | ||
|
||
override fun savePathToExecutableToProperties() { | ||
PropertiesComponent.getInstance().uvPath = Path.of(executable.get()) | ||
} | ||
|
||
override suspend fun setupEnvSdk(project: Project?, module: Module?, baseSdks: List<Sdk>, projectPath: String, homePath: String?, installPackages: Boolean): Result<Sdk> { | ||
if (module == null) { | ||
// FIXME: should not happen, proper error | ||
return Result.failure(Exception("module is null")) | ||
} | ||
|
||
val python = homePath?.let { Path.of(it) } | ||
return setupUvSdkUnderProgress(module, Path.of(projectPath), baseSdks, python) | ||
} | ||
|
||
override suspend fun detectExecutable() { | ||
model.detectUvExecutable() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. | ||
package com.jetbrains.python.sdk.uv | ||
|
||
import com.jetbrains.python.packaging.common.PythonPackage | ||
import com.jetbrains.python.packaging.common.PythonOutdatedPackage | ||
import com.jetbrains.python.packaging.common.PythonPackageSpecification | ||
import java.nio.file.Path | ||
|
||
interface UvCli { | ||
suspend fun runUv(workingDir: Path, vararg args: String): Result<String> | ||
} | ||
|
||
interface UvLowLevel { | ||
suspend fun initializeEnvironment(init: Boolean, python: Path?): Result<Path> | ||
|
||
suspend fun listPackages(): Result<List<PythonPackage>> | ||
suspend fun listOutdatedPackages(): Result<List<PythonOutdatedPackage>> | ||
|
||
suspend fun installPackage(name: PythonPackageSpecification, options: List<String>): Result<Unit> | ||
suspend fun uninstallPackage(name: PythonPackage): Result<Unit> | ||
} |
Oops, something went wrong.