Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure Windows Store takes precedence over Registry and fix Conda locators #23463

Merged
merged 6 commits into from
May 24, 2024

Conversation

DonJayamanne
Copy link

No description provided.

@DonJayamanne DonJayamanne added no-changelog No news entry required skip package*.json package.json and package-lock.json don't both need updating skip tests Updates to tests unnecessary labels May 22, 2024
@DonJayamanne DonJayamanne changed the title Logging for Windows Store Locator Ensure Windows Store takes precedence over Registry and fix Conda locators May 23, 2024
python_run_command: Some(vec![env.executable.to_str().unwrap().to_string()]),
arch: None,
..Default::default()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to do this in this PR, adding new fields was getting way too messy

serde_json::from_str::<CondaMetaPackageStructure>(&contents).ok()
{
if let Some(channel) = js.channel {
if channel.ends_with("64") {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Detection of 64bit for conda envs

@@ -202,6 +234,8 @@ fn get_conda_manager(path: &PathBuf) -> Option<EnvManager> {
executable_path: conda_exe,
version: Some(conda_pkg.version),
tool: EnvManagerType::Conda,
company: None,
company_display_name: None,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

company names we get from registry

// will be activated in python extension using first conda executable and -n base,
// I.e. base env of the first install will be activated instead of this.
// Hence lets always just give the path.
// name: Some("base".to_string()),
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is due to the fact that python extension supports only one conda exe today,

if let Ok(metadata) = exe.metadata() {
if let Ok(ctime) = metadata.created() {
if let Ok(ctime) = ctime.duration_since(UNIX_EPOCH) {
env.creation_time = Some(ctime.as_millis());
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding this, else I found we get some weird behaviour

let mut result = get_registry_pythons("PythonCore").unwrap_or_default();
environments.append(&mut result);

let mut result = get_registry_pythons_anaconda(self.conda_locator) ;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No more hardcoding of PythonCore and CondaAnalytics,
the code is now generic and will also detect conda envs

for file in std::fs::read_dir(apps_path).ok()?.filter_map(Result::ok) {
let path = file.path();
trace!("Searching for Windows Store Python in {:?}", apps_path);
let folder_version_regex =
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes as per discussion, to search for python3.10.exe and the PythonSoftwareFoundation.Python3.10_.... folders instead of using file and dir exists.

* @param env The environment to get the interpreter information for.
* @param priority The priority of the request.
*/
getMandatoryEnvironmentInfo(
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was required, else we end up resolving Python environments even when we have almost all of the info.
E.g. for windows store we know the version is 3.10.X, the typescript code extracts this today.
However we fully resolve this unnecessarily,
Now, added a different method to ensure we only resolve what we need to.

The old resolve will do a full resolve.

This now makes the discovery even faster, as we do not spawn envs at all, not unless we need to

if (isEnvLackingPython) {
// TODO: Shouldn't this only apply to conda, how else can we have an environment and not have Python in it?
// If thats the case, then this should be gated on environment.kind === PythonEnvKind.Conda
if (isEnvLackingPython && environment.kind !== PythonEnvKind.MicrosoftStore) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks wrong, but I do not want to fix this just yet.
E.g. I found that for MS store the exe is not in the same location as the sysPrefix, as a result we end up spawning the python process no matter what.
Thats a bug in the code, as in MS Store the exe is in a different location.

Also to my knowledge, this code should only apply to conda.

} else {
const { ctime, mtime } = await getFileInfo(resolvedEnv.executable.filename);
resolvedEnv.executable.ctime = ctime;
resolvedEnv.executable.mtime = mtime;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More fixes to ensure we avoid more unnecessary I/O operations in node

@DonJayamanne DonJayamanne marked this pull request as ready for review May 24, 2024 00:32
@DonJayamanne DonJayamanne enabled auto-merge (squash) May 24, 2024 00:33
@DonJayamanne DonJayamanne merged commit 594c9c0 into main May 24, 2024
77 checks passed
@DonJayamanne DonJayamanne deleted the addLoggingForWindowsStoreLC branch May 24, 2024 00:33
@vscodenpa vscodenpa added this to the May 2024 milestone May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-changelog No news entry required skip package*.json package.json and package-lock.json don't both need updating skip tests Updates to tests unnecessary
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants