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

Issues with detection of Python on codespaces #64

Open
DonJayamanne opened this issue Jun 28, 2024 · 1 comment
Open

Issues with detection of Python on codespaces #64

DonJayamanne opened this issue Jun 28, 2024 · 1 comment
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug

Comments

@DonJayamanne
Copy link
Collaborator

DonJayamanne commented Jun 28, 2024

##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 DonJayamanne added the bug Issue identified by VS Code Team member as probable bug label Jun 28, 2024
@DonJayamanne DonJayamanne self-assigned this Jun 28, 2024
@DonJayamanne DonJayamanne changed the title Detect Python envs in codespaces without spawning and duplicating Issies with detection of Python on codespaces Jun 28, 2024
@DonJayamanne
Copy link
Collaborator Author

Solution for Problem 2

  • Find the real file of the exe (e.g. /usr/local/python/current/bin/python or /usr/local/python/current/bin/python3)
  • If the file is still in the same directory, then we know what the real exe is, in this case it is /usr/local/python/current/bin/python3.10
  • Use this real exe to run Python and get the version and sys prefix information

@karthiknadig karthiknadig changed the title Issies with detection of Python on codespaces Issues with detection of Python on codespaces Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

No branches or pull requests

1 participant