python: Re-land usage of source file path in toolchain picker (#31893)

This reverts commit 1e55e88c18.

Closes #ISSUE

Release Notes:

- Python toolchain selector now uses path to the closest pyproject.toml
as a basis for picking a toolchain. All files under the same
pyproject.toml (in filesystem hierarchy) will share a single virtual
environment. It is possible to have multiple Python virtual environments
selected for disjoint parts of the same project.
This commit is contained in:
Piotr Osiewicz 2025-06-02 18:29:06 +02:00 committed by GitHub
parent 2ebe16a52f
commit 9dd18e5ee1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 195 additions and 92 deletions

View file

@ -35,6 +35,7 @@ pub use git_store::{
ConflictRegion, ConflictSet, ConflictSetSnapshot, ConflictSetUpdate,
git_traversal::{ChildEntriesGitIter, GitEntry, GitEntryRef, GitTraversal},
};
pub use manifest_tree::ManifestTree;
use anyhow::{Context as _, Result, anyhow};
use buffer_store::{BufferStore, BufferStoreEvent};
@ -874,11 +875,13 @@ impl Project {
cx.new(|cx| ContextServerStore::new(worktree_store.clone(), cx));
let environment = cx.new(|_| ProjectEnvironment::new(env));
let manifest_tree = ManifestTree::new(worktree_store.clone(), cx);
let toolchain_store = cx.new(|cx| {
ToolchainStore::local(
languages.clone(),
worktree_store.clone(),
environment.clone(),
manifest_tree.clone(),
cx,
)
});
@ -946,6 +949,7 @@ impl Project {
prettier_store.clone(),
toolchain_store.clone(),
environment.clone(),
manifest_tree,
languages.clone(),
client.http_client(),
fs.clone(),
@ -3084,16 +3088,13 @@ impl Project {
path: ProjectPath,
language_name: LanguageName,
cx: &App,
) -> Task<Option<ToolchainList>> {
if let Some(toolchain_store) = self.toolchain_store.clone() {
) -> Task<Option<(ToolchainList, Arc<Path>)>> {
if let Some(toolchain_store) = self.toolchain_store.as_ref().map(Entity::downgrade) {
cx.spawn(async move |cx| {
cx.update(|cx| {
toolchain_store
.read(cx)
.list_toolchains(path, language_name, cx)
})
.ok()?
.await
toolchain_store
.update(cx, |this, cx| this.list_toolchains(path, language_name, cx))
.ok()?
.await
})
} else {
Task::ready(None)