Skip to content

Commit

Permalink
Support uv
Browse files Browse the repository at this point in the history
  • Loading branch information
shirayu committed Sep 21, 2024
1 parent 738992a commit 4428056
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/configSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,15 @@ export class PythonSettings implements IPythonSettings {
return pythonBinFromPath(process.env.CONDA_PREFIX);
}

// `pyenv local` creates `.python-version`, but not `PYENV_VERSION`
let p = path.join(this.workspaceRoot, '.python-version');
// `pyenv local` and `uv` creates `.python-version`
p = path.join(this.workspaceRoot, '.python-version');
if (fs.existsSync(p)) {
// uv creates `.python-version` and `.venv`
const p2 = path.join(this.workspaceRoot, '.venv');
if (fs.existsSync(p) && fs.existsSync(p2)) {
return pythonBinFromPath(p2);
}
// `pyenv local` creates `.python-version`, but not `PYENV_VERSION`
if (!process.env.PYENV_VERSION) {
// pyenv local can special multiple Python, use first one only
process.env.PYENV_VERSION = fs.readFileSync(p).toString().trim().split('\n')[0];
Expand Down

0 comments on commit 4428056

Please sign in to comment.