Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
using Microsoft.PythonTools.Project;
using Microsoft.PythonTools.Utility;
using Microsoft.VisualStudio.LanguageServer.Client;
using Microsoft.VisualStudio.LanguageServer.Protocol;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.Text;
Expand Down Expand Up @@ -455,7 +456,6 @@ private LanguageServerSettings.PythonSettings GetSettings(Uri scopeUri = null) {

}
private void OnInterpreterChanged(object sender, EventArgs e) {
UpdateInterpreterExcludes();
OnSettingsChanged(sender, e);
}

Expand All @@ -475,7 +475,18 @@ private void OnAnalysisComplete(object sender, EventArgs e) {
private void OnReanalyzeChanged(object sender, EventArgs e) {
try {
Debug.WriteLine("Reanalyze Changed");
_deferredSettingsChangedTimer.Change(_defaultSettingsDelayMS, Timeout.Infinite);

// Packages have changes, so send a workspace/didChangeWatchedFiles for the env directory.
this._clientContexts.ForEach(context => {
var createEvent = new FileEvent();
createEvent.FileChangeType = FileChangeType.Changed;
createEvent.Uri = new Uri(CommonUtils.GetParent(context.InterpreterConfiguration.InterpreterPath));
var didChangeParams = new DidChangeWatchedFilesParams();
didChangeParams.Changes = new FileEvent[] { createEvent };
_rpc.NotifyWithParameterObjectAsync(Methods.WorkspaceDidChangeWatchedFiles.Name, didChangeParams);
});
Comment thread
bschnurr marked this conversation as resolved.


} catch (ObjectDisposedException) {
}
}
Expand Down Expand Up @@ -524,24 +535,11 @@ private void OnWorkspaceFolderWatched(object sender, EventArgs e) {

private void WatchedFilesRegistered(object sender, DidChangeWatchedFilesRegistrationOptions e) {
// Add the file globs to our listener. It will listen to the globs
UpdateInterpreterExcludes();
_fileListener?.AddPatterns(e.Watchers);

}

// By default Pylance will tell us to watch everything under the workspace with pattern "**/*"
// we can exclude the interpreter directory because we already have package managers listening to them
private void UpdateInterpreterExcludes() {
this._clientContexts.ForEach(context => {

if (PathUtils.IsSubpathOf(context.RootPath, context.InterpreterConfiguration.InterpreterPath)) {
var pattern = CommonUtils.GetRelativeFilePath(context.RootPath, context.InterpreterConfiguration.GetPrefixPath()).TrimEnd('\\') + "/**/*";
var watcher = new FileSystemWatcher() { GlobPattern = pattern };
this._fileListener.AddExclude(watcher);
}

});
}

private void CreateClientContexts() {
if (PythonWorkspaceContextProvider.Workspace != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ private static async Task<PythonInterpreterInformation> CreateEnvironmentInfo(st
var windowsInterpreterPath = Path.Combine(prefixPath, CondaEnvironmentFactoryConstants.WindowsExecutable);

if (!File.Exists(interpreterPath)) {
Debug.WriteLine($"[CondaEnv] Python Interpreter not found for environment '{name}' (prefix: '{prefixPath}'). Expected at: {interpreterPath}");
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,16 @@ public static CondaEnvironmentManager Create(string condaPath) {
return new CondaEnvironmentManager(condaPath);
}

// Creates a new conda environment with the given name or path, installing the specified packages. 'conda create -n name python pkg1 pkg2 ... -y'
public async Task<bool> CreateAsync(string newEnvNameOrPath, IEnumerable<PackageSpec> packageSpecs, ICondaEnvironmentManagerUI ui, CancellationToken ct) {
bool success = false;
using (await _working.LockAsync(ct)) {
var args = new[] {
"create",
IsAbsolutePath(newEnvNameOrPath) ? "-p" : "-n",
ProcessOutput.QuoteSingleArgument(newEnvNameOrPath),
"-y",
}.Union(packageSpecs.Select(s => s.FullSpec));
"python",
Comment thread
bschnurr marked this conversation as resolved.
}.Union(packageSpecs.Select(s => s.FullSpec)).Append("-y");

var operation = "conda " + string.Join(" ", args);

Expand Down