microsoft / python-environment-tools

MIT License
159 stars 15 forks source link

Issues with detection of Python on codespaces #64

Open DonJayamanne opened 3 months ago

DonJayamanne commented 3 months ago

Test environment

Create a codespace from https://github.com/github/codespaces-jupyter

Problem 1: Two instead of 1

The following two envs are the same, curren is a symlink to 3.10.13

Problem 2 : Incorrect sys.prefix

The exes /usr/local/python/current/bin/python and /usr/local/python/current/bin/python3 are symlinks to the same exe /usr/local/python/3.10.13/bin/python3.10 However they produce different sys.prefix values.

Problem 3: We are spawning

[2024-06-28T04:24:37Z WARN  pet::locators] Unknown Env ("/home/codespace/.python/current/bin/python") in Path resolved as ResolvedPythonEnv { executable: "/home/codespace/.python/current/bin/python", prefix: "/usr/local/python/3.10.13", version: "3.10.13.final.0", is64_bit: true, symlink: None } and reported as GlobalPaths
Environment (GlobalPaths)
   Executable  : /home/codespace/.python/current/bin/python
   Version     : 3.10.13.final.0
   Prefix      : /usr/local/python/3.10.13
   Architecture: x64
   Symlinks    : "/home/codespace/.python/current/bin/python"
               : "/home/codespace/.python/current/bin/python3"
               : "/home/codespace/.python/current/bin/python3.10"
[2024-06-28T04:24:37Z TRACE pet_python_utils::env] Executing Python: /home/codespace/.python/current/bin/python3 -c import json, sys; print('093385e9-59f7-4a16-a604-14bf206256fe');print(json.dumps({'version': '.'.join(str(n) for n in sys.version_info), 'sys_prefix': sys.prefix, 'executable': sys.executable, 'is64_bit': sys.maxsize > 2**32}))
[2024-06-28T04:24:37Z WARN  pet::locators] Unknown Env ("/usr/local/python/current/bin/python") in Path resolved as ResolvedPythonEnv { executable: "/usr/local/python/current/bin/python", prefix: "/usr/local/python/3.10.13", version: "3.10.13.final.0", is64_bit: true, symlink: None } and reported as GlobalPaths
Environment (GlobalPaths)
   Executable  : /usr/local/python/current/bin/python
   Version     : 3.10.13.final.0
   Prefix      : /usr/local/python/3.10.13
   Architecture: x64
   Symlinks    : "/usr/local/python/current/bin/python"
               : "/usr/local/python/current/bin/python3"
               : "/usr/local/python/current/bin/python3.10"
DonJayamanne commented 3 months ago

Solution for Problem 2