Skip to content

Commit 22640f8

Browse files
committed
fix #500
1 parent af7560d commit 22640f8

4 files changed

Lines changed: 34 additions & 10 deletions

File tree

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,11 @@
499499
"default": "python",
500500
"description": "Path to Python, you can use a custom version of Python by modifying this setting to include the full path."
501501
},
502+
"python.jediPath": {
503+
"type": "string",
504+
"default": "",
505+
"description": "Path to directory containing the Jedi library (this path will contain the 'Jedi' sub directory)."
506+
},
502507
"python.sortImports.args": {
503508
"type": "array",
504509
"description": "Arguments passed in. Each argument is a separate item in the array.",

pythonFiles/completion.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -408,17 +408,21 @@ def watch(self):
408408

409409
if __name__ == '__main__':
410410
jediPreview = False
411+
cachePrefix = 'v'
411412
if len(sys.argv) > 0 and sys.argv[1] == 'preview':
412413
jediPath = os.path.join(os.path.dirname(__file__), 'preview', 'jedi')
413414
jediPreview = True
415+
elif len(sys.argv) > 0 and sys.argv[1] == 'custom':
416+
jediPath = sys.argv[2]
417+
jediPreview = True
418+
cachePrefix = 'custom_v'
414419
else:
415420
jediPath = os.path.join(os.path.dirname(__file__), 'release')
416-
417421
sys.path.insert(0, jediPath)
418-
import jedi
422+
import jedi
419423
if jediPreview:
420424
jedi.settings.cache_directory = os.path.join(
421-
jedi.settings.cache_directory, 'v' + jedi.__version__.replace('.', ''))
425+
jedi.settings.cache_directory, cachePrefix + jedi.__version__.replace('.', ''))
422426
# remove jedi from path after we import it so it will not be completed
423427
sys.path.pop(0)
424428
JediCompletion().watch()

src/client/common/configSettings.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import * as path from 'path';
77

88
export interface IPythonSettings {
99
pythonPath: string;
10+
jediPath: string;
1011
devOptions: string[];
1112
linting: ILintingSettings;
1213
formatting: IFormattingSettings;
@@ -115,6 +116,13 @@ export class PythonSettings extends EventEmitter implements IPythonSettings {
115116
let pythonSettings = vscode.workspace.getConfiguration('python');
116117
this.pythonPath = systemVariables.resolveAny(pythonSettings.get<string>('pythonPath'));
117118
this.pythonPath = getAbsolutePath(this.pythonPath, IS_TEST_EXECUTION ? __dirname : workspaceRoot);
119+
this.jediPath = systemVariables.resolveAny(pythonSettings.get<string>('jediPath'));
120+
if (typeof this.jediPath === 'string' && this.jediPath.length > 0) {
121+
this.jediPath = getAbsolutePath(this.jediPath, IS_TEST_EXECUTION ? __dirname : workspaceRoot);
122+
}
123+
else {
124+
this.jediPath = '';
125+
}
118126
this.devOptions = systemVariables.resolveAny(pythonSettings.get<any[]>('devOptions'));
119127
this.devOptions = Array.isArray(this.devOptions) ? this.devOptions : [];
120128
let lintingSettings = systemVariables.resolveAny(pythonSettings.get<ILintingSettings>('linting'));
@@ -203,7 +211,7 @@ export class PythonSettings extends EventEmitter implements IPythonSettings {
203211

204212
// Support for travis
205213
this.unitTest = this.unitTest ? this.unitTest : {
206-
promptToConfigure:true,
214+
promptToConfigure: true,
207215
nosetestArgs: [], nosetestPath: 'nosetest', nosetestsEnabled: false,
208216
outputWindow: 'python',
209217
pyTestArgs: [], pyTestEnabled: false, pyTestPath: 'pytest',
@@ -241,6 +249,7 @@ export class PythonSettings extends EventEmitter implements IPythonSettings {
241249
}
242250

243251
public pythonPath: string;
252+
public jediPath: string;
244253
public devOptions: string[];
245254
public linting: ILintingSettings;
246255
public formatting: IFormattingSettings;

src/client/providers/jediProxy.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,20 @@ function spawnProcess(dir: string) {
192192

193193
logger.log('child_process.spawn in jediProxy', 'Value of pythonSettings.pythonPath is :' + pythonSettings.pythonPath);
194194
const args = ["completion.py"];
195-
if (Array.isArray(pythonSettings.devOptions) &&
196-
pythonSettings.devOptions.some(item => item.toUpperCase().trim() === 'USERELEASEAUTOCOMP')) {
197-
// Use standard version of jedi library
198-
args.push('std');
195+
if (typeof pythonSettings.jediPath !== 'string' || pythonSettings.jediPath.length === 0) {
196+
if (Array.isArray(pythonSettings.devOptions) &&
197+
pythonSettings.devOptions.some(item => item.toUpperCase().trim() === 'USERELEASEAUTOCOMP')) {
198+
// Use standard version of jedi library
199+
args.push('std');
200+
}
201+
else {
202+
// Use preview version of jedi library
203+
args.push('preview');
204+
}
199205
}
200206
else {
201-
// Use preview version of jedi library
202-
args.push('preview');
207+
args.push('custom');
208+
args.push(pythonSettings.jediPath);
203209
}
204210
proc = child_process.spawn(pythonSettings.pythonPath, args, {
205211
cwd: dir,

0 commit comments

Comments
 (0)