Skip to content

Commit b65ea3b

Browse files
authored
Use nox to install packages (#22381)
1 parent a7262b8 commit b65ea3b

File tree

4 files changed

+52
-97
lines changed

4 files changed

+52
-97
lines changed

gulpfile.js

Lines changed: 0 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ const nativeDependencyChecker = require('node-has-native-dependencies');
2020
const flat = require('flat');
2121
const { argv } = require('yargs');
2222
const os = require('os');
23-
const rmrf = require('rimraf');
2423
const typescript = require('typescript');
2524

2625
const tsProject = ts.createProject('./tsconfig.json', { typescript });
@@ -243,100 +242,6 @@ gulp.task('prePublishBundle', gulp.series('webpack', 'renameSourceMaps'));
243242
gulp.task('checkDependencies', gulp.series('checkNativeDependencies'));
244243
gulp.task('prePublishNonBundle', gulp.series('compile'));
245244

246-
gulp.task('installPythonRequirements', async () => {
247-
let args = [
248-
'-m',
249-
'pip',
250-
'--disable-pip-version-check',
251-
'install',
252-
'--no-user',
253-
'-t',
254-
'./pythonFiles/lib/python',
255-
'--no-cache-dir',
256-
'--implementation',
257-
'py',
258-
'--no-deps',
259-
'--upgrade',
260-
'-r',
261-
'./requirements.txt',
262-
];
263-
await spawnAsync(process.env.CI_PYTHON_PATH || 'python', args, undefined, true)
264-
.then(() => true)
265-
.catch((ex) => {
266-
console.error("Failed to install requirements using 'python'", ex);
267-
return false;
268-
});
269-
270-
args = [
271-
'-m',
272-
'pip',
273-
'--disable-pip-version-check',
274-
'install',
275-
'--no-user',
276-
'-t',
277-
'./pythonFiles/lib/jedilsp',
278-
'--no-cache-dir',
279-
'--implementation',
280-
'py',
281-
'--no-deps',
282-
'--upgrade',
283-
'-r',
284-
'./pythonFiles/jedilsp_requirements/requirements.txt',
285-
];
286-
await spawnAsync(process.env.CI_PYTHON_PATH || 'python', args, undefined, true)
287-
.then(() => true)
288-
.catch((ex) => {
289-
console.error("Failed to install Jedi LSP requirements using 'python'", ex);
290-
return false;
291-
});
292-
});
293-
294-
// See https://github.com/microsoft/vscode-python/issues/7136
295-
gulp.task('installDebugpy', async () => {
296-
// Install dependencies needed for 'install_debugpy.py'
297-
const depsArgs = [
298-
'-m',
299-
'pip',
300-
'--disable-pip-version-check',
301-
'install',
302-
'--no-user',
303-
'-t',
304-
'./pythonFiles/lib/temp',
305-
'-r',
306-
'./build/build-install-requirements.txt',
307-
];
308-
await spawnAsync(process.env.CI_PYTHON_PATH || 'python', depsArgs, undefined, true)
309-
.then(() => true)
310-
.catch((ex) => {
311-
console.error("Failed to install dependencies need by 'install_debugpy.py' using 'python'", ex);
312-
return false;
313-
});
314-
315-
// Install new DEBUGPY with wheels for python
316-
const wheelsArgs = ['./pythonFiles/install_debugpy.py'];
317-
const wheelsEnv = { PYTHONPATH: './pythonFiles/lib/temp' };
318-
await spawnAsync(process.env.CI_PYTHON_PATH || 'python', wheelsArgs, wheelsEnv, true)
319-
.then(() => true)
320-
.catch((ex) => {
321-
console.error("Failed to install DEBUGPY wheels using 'python'", ex);
322-
return false;
323-
});
324-
325-
// Download get-pip.py
326-
const getPipArgs = ['./pythonFiles/download_get_pip.py'];
327-
const getPipEnv = { PYTHONPATH: './pythonFiles/lib/temp' };
328-
await spawnAsync(process.env.CI_PYTHON_PATH || 'python', getPipArgs, getPipEnv, true)
329-
.then(() => true)
330-
.catch((ex) => {
331-
console.error("Failed to download get-pip wheels using 'python'", ex);
332-
return false;
333-
});
334-
335-
rmrf.sync('./pythonFiles/lib/temp');
336-
});
337-
338-
gulp.task('installPythonLibs', gulp.series('installPythonRequirements', 'installDebugpy'));
339-
340245
function spawnAsync(command, args, env, rejectOnStdErr = false) {
341246
env = env || {};
342247
env = { ...process.env, ...env };

noxfile.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
4+
import pathlib
5+
import nox
6+
import shutil
7+
8+
9+
@nox.session()
10+
def install_python_libs(session: nox.Session):
11+
requirements = [
12+
("./pythonFiles/lib/python", "./requirements.txt"),
13+
(
14+
"./pythonFiles/lib/jedilsp",
15+
"./pythonFiles/jedilsp_requirements/requirements.txt",
16+
),
17+
]
18+
for target, file in requirements:
19+
session.install(
20+
"-t",
21+
target,
22+
"--no-cache-dir",
23+
"--implementation",
24+
"py",
25+
"--no-deps",
26+
"--require-hashes",
27+
"--only-binary",
28+
":all:",
29+
"-r",
30+
file,
31+
)
32+
33+
session.install("packaging")
34+
35+
# Install debugger
36+
session.run(
37+
"python",
38+
"./pythonFiles/install_debugpy.py",
39+
env={"PYTHONPATH": "./pythonFiles/lib/temp"},
40+
)
41+
42+
# Download get-pip script
43+
session.run(
44+
"python",
45+
"./pythonFiles/download_get_pip.py",
46+
env={"PYTHONPATH": "./pythonFiles/lib/temp"},
47+
)
48+
49+
if pathlib.Path("./pythonFiles/lib/temp").exists():
50+
shutil.rmtree("./pythonFiles/lib/temp")

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1646,7 +1646,6 @@
16461646
"nyc": "^15.0.0",
16471647
"prettier": "^2.0.2",
16481648
"rewiremock": "^3.13.0",
1649-
"rimraf": "^3.0.2",
16501649
"shortid": "^2.2.8",
16511650
"sinon": "^13.0.1",
16521651
"source-map-support": "^0.5.12",

scripts/onCreateCommand.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ pyenv exec python3.8 -m venv .venv
2626
source /workspaces/vscode-python/.venv/bin/activate
2727

2828
# Install required Python libraries.
29-
npx gulp installPythonLibs
29+
/workspaces/vscode-python/.venv/bin/python -m pip install nox
30+
nox --session install_python_libs
3031

3132
/workspaces/vscode-python/.venv/bin/python -m pip install -r build/test-requirements.txt
3233
/workspaces/vscode-python/.venv/bin/python -m pip install -r build/functional-test-requirements.txt

0 commit comments

Comments
 (0)