Skip to content

Commit 66ec955

Browse files
authored
Update debugger to ptvsd latest (microsoft#9653)
* Update debugger to ptvsd v5.0.0a12 * Add news item * Use `--pre` to avoid updating debugger to often * Fix issues with debugger installation * fix build * Fix merge issues
1 parent 3eca2a3 commit 66ec955

File tree

6 files changed

+62
-35
lines changed

6 files changed

+62
-35
lines changed

build/ci/templates/steps/build.yml

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,56 +14,55 @@
1414
steps:
1515
- template: initialization.yml
1616
parameters:
17-
PythonVersion: $(PythonVersion)
18-
workingDirectory: $(Build.SourcesDirectory)
19-
compile: 'false'
17+
PythonVersion: $(PythonVersion)
18+
workingDirectory: $(Build.SourcesDirectory)
19+
compile: 'false'
2020

2121
- bash: |
2222
python -m pip install -U pip
2323
python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python --no-cache-dir --implementation py --no-deps --upgrade -r requirements.txt
2424
python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python/old_ptvsd --no-cache-dir --implementation py --no-deps --upgrade 'ptvsd==4.3.2'
25-
python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python/new_ptvsd/no_wheels --no-cache-dir --implementation py --no-deps --upgrade 'ptvsd==5.0.0a11'
25+
python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python/new_ptvsd/no_wheels --no-cache-dir --implementation py --no-deps --upgrade --pre ptvsd
2626
failOnStderr: true
27-
displayName: "pip install requirements"
27+
displayName: 'pip install requirements'
2828
29-
- task: PythonScript@0
30-
displayName: "Install PTVSD wheels"
31-
inputs:
32-
scriptSource: "filePath"
33-
scriptPath: "./pythonFiles/install_ptvsd.py"
34-
failOnStderr: true
29+
- bash: |
30+
python -m pip --disable-pip-version-check install -r build/debugger-install-requirements.txt
31+
python ./pythonFiles/install_ptvsd.py
32+
failOnStderr: true
33+
displayName: 'Install PTVSD wheels'
3534
3635
- bash: npm run clean
37-
displayName: "Clean"
36+
displayName: 'Clean'
3837

3938
# This is a slow process, hence do this only on master and release branches.
4039
# I.e. skip on in PRs.
4140
- bash: npm run checkDependencies
42-
displayName: "Check Dependencies"
41+
displayName: 'Check Dependencies'
4342
condition: and(succeeded(), or(eq(variables['Build.SourceBranchName'], 'master'), startsWith(variables['Build.SourceBranchName'], 'release')))
4443

4544
- bash: |
4645
npm run updateBuildNumber -- --buildNumber $BUILD_BUILDID
47-
displayName: "Update dev Version of Extension"
46+
displayName: 'Update dev Version of Extension'
4847
condition: and(succeeded(), eq(variables['Build.SourceBranchName'], 'master'))
4948
5049
- bash: |
5150
npm run updateBuildNumber -- --buildNumber $BUILD_BUILDID --updateChangelog
52-
displayName: "Update release Version of Extension"
51+
displayName: 'Update release Version of Extension'
5352
condition: and(succeeded(), startsWith(variables['Build.SourceBranchName'], 'release'))
5453
5554
- bash: |
5655
npm run package
57-
displayName: "Build VSIX"
56+
displayName: 'Build VSIX'
5857
5958
- task: CopyFiles@2
6059
inputs:
61-
contents: "*.vsix"
60+
contents: '*.vsix'
6261
targetFolder: $(Build.ArtifactStagingDirectory)
63-
displayName: "Copy VSIX"
62+
displayName: 'Copy VSIX'
6463

6564
- task: PublishBuildArtifacts@1
6665
inputs:
6766
pathtoPublish: $(Build.ArtifactStagingDirectory)
6867
artifactName: VSIX
69-
displayName: "Publish VSIX to Artifacts"
68+
displayName: 'Publish VSIX to Artifacts'

build/ci/templates/test_phases.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ steps:
9797
python -m pip install --upgrade -r build/test-requirements.txt
9898
python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python --no-cache-dir --implementation py --no-deps --upgrade -r requirements.txt
9999
python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python/old_ptvsd --no-cache-dir --implementation py --no-deps --upgrade 'ptvsd==4.3.2'
100-
python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python/new_ptvsd/no_wheels --no-cache-dir --implementation py --no-deps --upgrade 'ptvsd==5.0.0a11'
100+
python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python/new_ptvsd/no_wheels --no-cache-dir --implementation py --no-deps --upgrade --pre ptvsd
101101
displayName: 'pip install system test requirements'
102102
condition: and(succeeded(), eq(variables['NeedsPythonTestReqs'], 'true'))
103103
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Requirements needed to run install_ptvsd.py
2+
packaging

gulpfile.js

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const nativeDependencyChecker = require('node-has-native-dependencies');
2929
const flat = require('flat');
3030
const argv = require('yargs').argv;
3131
const os = require('os');
32+
const rmrf = require('rimraf');
3233

3334
const isCI = process.env.TRAVIS === 'true' || process.env.TF_BUILD !== undefined;
3435

@@ -283,18 +284,35 @@ gulp.task('installPythonRequirements', async () => {
283284

284285
// See https://github.com/microsoft/vscode-python/issues/7136
285286
gulp.task('installNewPtvsd', async () => {
287+
// Install dependencies needed for 'install_ptvsd.py'
288+
const depsArgs = ['-m', 'pip', '--disable-pip-version-check', 'install', '-t', './pythonFiles/lib/temp', '-r', './build/debugger-install-requirements.txt'];
289+
const successWithWheelsDeps = await spawnAsync(process.env.CI_PYTHON_PATH || 'python3', depsArgs)
290+
.then(() => true)
291+
.catch(ex => {
292+
console.error("Failed to install new PTVSD wheels using 'python3'", ex);
293+
return false;
294+
});
295+
if (!successWithWheelsDeps) {
296+
console.info("Failed to install dependencies need by 'install_ptvsd.py' using 'python3', attempting to install using 'python'");
297+
await spawnAsync('python', depsArgs).catch(ex => console.error("Failed to install dependencies need by 'install_ptvsd.py' using 'python'", ex));
298+
}
299+
286300
// Install new PTVSD with wheels for python 3.7
287-
const successWithWheels = await spawnAsync(process.env.CI_PYTHON_PATH || 'python3', ['./pythonFiles/install_ptvsd.py'])
301+
const wheelsArgs = ['./pythonFiles/install_ptvsd.py'];
302+
const wheelsEnv = { PYTHONPATH: './pythonFiles/lib/temp' };
303+
const successWithWheels = await spawnAsync(process.env.CI_PYTHON_PATH || 'python3', wheelsArgs, wheelsEnv)
288304
.then(() => true)
289305
.catch(ex => {
290306
console.error("Failed to install new PTVSD wheels using 'python3'", ex);
291307
return false;
292308
});
293309
if (!successWithWheels) {
294310
console.info("Failed to install new PTVSD wheels using 'python3', attempting to install using 'python'");
295-
await spawnAsync('python', args).catch(ex => console.error("Failed to install PTVSD 5.0 wheels using 'python'", ex));
311+
await spawnAsync('python', wheelsArgs, wheelsEnv).catch(ex => console.error("Failed to install PTVSD 5.0 wheels using 'python'", ex));
296312
}
297313

314+
rmrf.sync('./pythonFiles/lib/temp');
315+
298316
// Install source only version of new PTVSD for use with all other python versions.
299317
const args = [
300318
'-m',
@@ -308,7 +326,8 @@ gulp.task('installNewPtvsd', async () => {
308326
'py',
309327
'--no-deps',
310328
'--upgrade',
311-
'ptvsd==5.0.0a11'
329+
'--pre',
330+
'ptvsd'
312331
];
313332
const successWithoutWheels = await spawnAsync(process.env.CI_PYTHON_PATH || 'python3', args)
314333
.then(() => true)

news/2 Fixes/9652.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Update debugger version to `ptvsd` v5.0.0a12.

pythonFiles/install_ptvsd.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,38 @@
33
import os
44
import urllib.request as url_lib
55
import zipfile
6+
from packaging.version import parse as version_parser
67

78

89
EXTENSION_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
910
DEBUGGER_DEST = os.path.join(EXTENSION_ROOT, "pythonFiles", "lib", "python", "new_ptvsd", "wheels")
1011
DEBUGGER_PACKAGE = "ptvsd"
11-
DEBUGGER_VERSION = "5.0.0a11"
1212
DEBUGGER_PYTHON_VERSIONS = ("cp37",)
1313

1414

1515
def _contains(s, parts=()):
1616
return any(p for p in parts if p in s)
1717

1818

19-
def _get_debugger_wheel_urls():
19+
def _get_package_data():
2020
json_uri = "https://pypi.org/pypi/{0}/json".format(DEBUGGER_PACKAGE)
2121
# Response format: https://warehouse.readthedocs.io/api-reference/json/#project
2222
# Release metadata format: https://github.com/pypa/interoperability-peps/blob/master/pep-0426-core-metadata.rst
2323
with url_lib.urlopen(json_uri) as response:
24-
json_response = json.loads(response.read())
25-
return list(
26-
r["url"]
27-
for r in json_response["releases"][DEBUGGER_VERSION]
28-
if _contains(r["url"], DEBUGGER_PYTHON_VERSIONS)
29-
)
24+
return json.loads(response.read())
3025

3126

32-
def _download_and_extract(root, url):
27+
def _get_debugger_wheel_urls(data, version):
28+
return list(
29+
r["url"]
30+
for r in data["releases"][version]
31+
if _contains(r["url"], DEBUGGER_PYTHON_VERSIONS)
32+
)
33+
34+
35+
def _download_and_extract(root, url, version):
3336
root = os.getcwd() if root is None or root == "." else root
34-
prefix = os.path.join("ptvsd-{0}.data".format(DEBUGGER_VERSION), "purelib")
37+
prefix = os.path.join("ptvsd-{0}.data".format(version), "purelib")
3538
with url_lib.urlopen(url) as response:
3639
# Extract only the contents of the purelib subfolder (parent folder of ptvsd),
3740
# since ptvsd files rely on the presence of a 'ptvsd' folder.
@@ -49,8 +52,11 @@ def _download_and_extract(root, url):
4952

5053

5154
def main(root):
52-
for url in _get_debugger_wheel_urls():
53-
_download_and_extract(root, url)
55+
data = _get_package_data()
56+
latest_version = max(data["releases"].keys(), key=version_parser)
57+
58+
for url in _get_debugger_wheel_urls(data, latest_version):
59+
_download_and_extract(root, url, latest_version)
5460

5561

5662
if __name__ == "__main__":

0 commit comments

Comments
 (0)