forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Support pyenv and direnv #854
Merged
Merged
Changes from all commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
6546892
Fix pylint search
76af122
Handle quote escapes in strings
5d4d022
Escapes in strings
29edac2
CR feedback
0492aab
Missing pip
d0a449f
Test
55197c3
Tests
f6a0123
Tests
d07d3ef
Mac python path
2b0cc92
Tests
3867ec2
Tests
85fc4ef
Test
00887a4
"Go To Python object" doesn't work
f89dd96
Proper detection and type population in virtual env
32394e2
Test fixes
2e9c039
Simplify venv check
ec563c7
Remove duplicates
2ad4475
Test
1ee0be2
Discover pylintrc better + tests
44665b9
Merge branch 'master' into 804
29d3925
Merge branch 'master' of https://github.com/Microsoft/vscode-python i…
04c5733
Undo change
37328a5
CR feedback
55ff4e5
Set interprereter before checking install
9a0cfa8
Merge master
023af49
Merge master
436e5a9
Fix typo and path compare on Windows
a53d815
Rename method
7f3e4fa
#815 - 'F' in flake8 means warning
da034f4
730 - same folder temp
71a508d
Properly resolve ~
4422811
Merge branch 'master' of https://github.com/Microsoft/vscode-python i…
6d91912
Test
ff6f6d2
Test
7446afb
Merge branch 'master' of https://github.com/Microsoft/vscode-python i…
a7b2854
Fix dot spacing
a9457f2
Merge branch 'master' of https://github.com/Microsoft/vscode-python i…
c7c07de
Remove banner
e9eec39
Delete banner code
7b5d76b
Add pyenv and direnv folders
d62a8e0
Merge branch 'master' of https://github.com/Microsoft/vscode-python i…
66395c5
Basic venv path search tests
005f65e
PYENV_ROOT resolution
63e195c
PYENV_ROOT test
b142a49
Use ICurrentProcess
005875f
Fix travis
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
import { expect } from 'chai'; | ||
import { Container } from 'inversify'; | ||
import * as os from 'os'; | ||
import * as path from 'path'; | ||
import * as TypeMoq from 'typemoq'; | ||
import { Uri, WorkspaceFolder } from 'vscode'; | ||
import { IWorkspaceService } from '../../client/common/application/types'; | ||
import { IConfigurationService, ICurrentProcess, IPythonSettings } from '../../client/common/types'; | ||
import { EnvironmentVariables } from '../../client/common/variables/types'; | ||
import { GlobalVirtualEnvironmentsSearchPathProvider } from '../../client/interpreter/locators/services/globalVirtualEnvService'; | ||
import { WorkspaceVirtualEnvironmentsSearchPathProvider } from '../../client/interpreter/locators/services/workspaceVirtualEnvService'; | ||
import { ServiceContainer } from '../../client/ioc/container'; | ||
import { ServiceManager } from '../../client/ioc/serviceManager'; | ||
|
||
suite('Virtual environments', () => { | ||
let serviceManager: ServiceManager; | ||
let serviceContainer: ServiceContainer; | ||
let settings: TypeMoq.IMock<IPythonSettings>; | ||
let config: TypeMoq.IMock<IConfigurationService>; | ||
let workspace: TypeMoq.IMock<IWorkspaceService>; | ||
let process: TypeMoq.IMock<ICurrentProcess>; | ||
|
||
setup(async () => { | ||
const cont = new Container(); | ||
serviceManager = new ServiceManager(cont); | ||
serviceContainer = new ServiceContainer(cont); | ||
|
||
settings = TypeMoq.Mock.ofType<IPythonSettings>(); | ||
config = TypeMoq.Mock.ofType<IConfigurationService>(); | ||
workspace = TypeMoq.Mock.ofType<IWorkspaceService>(); | ||
process = TypeMoq.Mock.ofType<ICurrentProcess>(); | ||
|
||
config.setup(x => x.getSettings(TypeMoq.It.isAny())).returns(() => settings.object); | ||
|
||
serviceManager.addSingletonInstance<IConfigurationService>(IConfigurationService, config.object); | ||
serviceManager.addSingletonInstance<IWorkspaceService>(IWorkspaceService, workspace.object); | ||
serviceManager.addSingletonInstance<ICurrentProcess>(ICurrentProcess, process.object); | ||
}); | ||
|
||
test('Global search paths', async () => { | ||
const pathProvider = new GlobalVirtualEnvironmentsSearchPathProvider(serviceContainer); | ||
const envMap: EnvironmentVariables = {}; | ||
|
||
const homedir = os.homedir(); | ||
let folders = ['Envs', '.virtualenvs', '.pyenv', path.join('.pyenv', 'versions')]; | ||
let paths = pathProvider.getSearchPaths(); | ||
let expected = folders.map(item => path.join(homedir, item)); | ||
expect(paths).to.deep.equal(expected, 'Global search folder list is incorrect.'); | ||
|
||
process.setup(x => x.env).returns(() => envMap); | ||
// tslint:disable-next-line:no-string-literal | ||
envMap['PYENV_ROOT'] = path.join(homedir, 'some_folder'); | ||
paths = pathProvider.getSearchPaths(); | ||
|
||
folders = ['Envs', '.virtualenvs', 'some_folder', path.join('some_folder', 'versions')]; | ||
expected = folders.map(item => path.join(homedir, item)); | ||
expect(paths).to.deep.equal(expected, 'PYENV_ROOT not resolved correctly.'); | ||
}); | ||
|
||
test('Workspace search paths', async () => { | ||
settings.setup(x => x.venvPath).returns(() => `~${path.sep}foo`); | ||
|
||
const wsRoot = TypeMoq.Mock.ofType<WorkspaceFolder>(); | ||
wsRoot.setup(x => x.uri).returns(() => Uri.file('root')); | ||
|
||
const folder1 = TypeMoq.Mock.ofType<WorkspaceFolder>(); | ||
folder1.setup(x => x.uri).returns(() => Uri.file('dir1')); | ||
|
||
workspace.setup(x => x.getWorkspaceFolder(TypeMoq.It.isAny())).returns(() => wsRoot.object); | ||
workspace.setup(x => x.workspaceFolders).returns(() => [wsRoot.object, folder1.object]); | ||
|
||
const pathProvider = new WorkspaceVirtualEnvironmentsSearchPathProvider(serviceContainer); | ||
const paths = pathProvider.getSearchPaths(Uri.file('')); | ||
|
||
const homedir = os.homedir(); | ||
const expected = [path.join(homedir, 'foo'), `${path.sep}root`, `${path.sep}root${path.sep}.direnv`]; | ||
expect(paths).to.deep.equal(expected, 'Workspace venv folder search list does not match.'); | ||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol, I couldn't be bothered to identify the problem, I just created the folder with a dummy
.ts
file in theformatting
directory.You might want to merge
master
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okaaaay :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My solution was to ensure the directory always exists. I didn't check what code was looking for it.