Skip to content

Commit ff98bed

Browse files
committed
feat: adds ability to detect Python virtual envs
1 parent c44f083 commit ff98bed

File tree

13 files changed

+509
-134
lines changed

13 files changed

+509
-134
lines changed

package-lock.json

Lines changed: 266 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,7 @@
758758
"@typescript-eslint/parser": "^5.59.8",
759759
"@vscode/test-electron": "^2.3.2",
760760
"c8": "^7.13.0",
761+
"copy-webpack-plugin": "^11.0.0",
761762
"eslint": "^8.40.0",
762763
"eslint-plugin-import": "^2.27.5",
763764
"eslint-plugin-jsdoc": "^44.2.4",

scripts/get_pip_bin_dir.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import os
2+
import sysconfig
3+
4+
5+
def get_install_bin_dir() -> str:
6+
"""Get the path to the pip install directory for scripts (bin, Scripts).
7+
Works for virtualenv, conda, and system installs.
8+
9+
Returns
10+
-------
11+
str
12+
Path to the pip install directory for scripts (bin, Scripts).
13+
"""
14+
if ("VIRTUAL_ENV" in os.environ) or ("CONDA_PREFIX" in os.environ):
15+
return sysconfig.get_path("scripts")
16+
else:
17+
return sysconfig.get_path("scripts", f"{os.name}_user")
18+
19+
20+
if __name__ == "__main__":
21+
print(get_install_bin_dir())

src/format/provider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import * as vscode from 'vscode';
66
import which from 'which';
77

88
import { Logger } from '../services/logging';
9+
import { spawnAsPromise } from '../util/shell';
910
import {
1011
FORMATTERS,
1112
EXTENSION_ID,
1213
promptForMissingTool,
1314
getWholeFileRange,
14-
spawnAsPromise,
1515
pathRelToAbs,
1616
} from '../util/tools';
1717

src/lint/provider.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,13 @@ import {
2121
import { Logger } from '../services/logging';
2222
import { GlobPaths } from '../util/glob-paths';
2323
import { arraysEqual } from '../util/helper';
24+
import { spawnAsPromise, shellTask } from '../util/shell';
2425
import {
2526
EXTENSION_ID,
2627
resolveVariables,
2728
promptForMissingTool,
2829
isFreeForm,
29-
spawnAsPromise,
3030
isFortran,
31-
shellTask,
3231
} from '../util/tools';
3332

3433
import { GNULinter, GNUModernLinter, IntelLinter, LFortranLinter, NAGLinter } from './compilers';

src/lsp/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ import { LanguageClient, LanguageClientOptions, ServerOptions } from 'vscode-lan
1010

1111
import { RestartLS } from '../commands/commands';
1212
import { Logger } from '../services/logging';
13+
import { pipInstall } from '../util/python';
1314
import {
1415
EXTENSION_ID,
1516
FortranDocumentSelector,
1617
LS_NAME,
1718
isFortran,
1819
getOuterMostWorkspaceFolder,
19-
pipInstall,
2020
resolveVariables,
2121
} from '../util/tools';
2222

0 commit comments

Comments
 (0)