GeezerVison is showing github.com — Ship 2 versions of PTVSD in the extension (#7115) · tmayor/pythonVSCode@9183405
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: CONTRIBUTING.md +1-1Lines changed: 1 addition & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -36,7 +36,7 @@ cd vscode-python | 36 | 36 | npm ci | 37 | 37 | python3 -m venv .venv | 38 | 38 | # Activate the virtual environment as appropriate for your shell. | 39 | | -python3 -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python --no-cache-dir --implementation py --no-deps --upgrade -r requirements.txt | | 39 | +npx gulp installPythonLibs | 40 | 40 | # Optionally Update `launch.json` to set a value for the environment variable `CI_PYTHON_PATH` pointing to the fully qualified path of the above interpreter. | 41 | 41 | ``` | 42 | 42 | You may see warnings that ```The engine "vscode" appears to be invalid.```, you can ignore these. | |
Collapse file Copy file name to clipboardExpand all lines: build/ci/templates/build_compile_steps.yml +3-1Lines changed: 3 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 63 | 63 | - bash: | | 64 | 64 | python -m pip install -U pip | 65 | 65 | python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python --no-cache-dir --implementation py --no-deps --upgrade -r requirements.txt | | 66 | + 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' | 66 | 67 | failOnStderr: true | 67 | 68 | displayName: "pip install requirements" | 68 | 69 | condition: and(succeeded(), eq(variables['build'], 'true')) | | 71 | 72 | displayName: "Install PTVSD wheels" | 72 | 73 | inputs: | 73 | 74 | scriptSource: "filePath" | 74 | | - scriptPath: "./build/ci/install_ptvsd.py" | | 75 | + scriptPath: "./pythonFiles/install_ptvsd.py" | | 76 | + arguments: "--ci" | 75 | 77 | failOnStderr: true | 76 | 78 | condition: and(succeeded(), eq(variables['build'], 'true')) | 77 | 79 |
| |
Collapse file Copy file name to clipboardExpand all lines: build/ci/templates/test_phases.yml +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -179,6 +179,7 @@ steps: | 179 | 179 | python -m pip install -U pip | 180 | 180 | python -m pip install --upgrade -r build/test-requirements.txt | 181 | 181 | python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python --no-cache-dir --implementation py --no-deps --upgrade -r requirements.txt | | 182 | + 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' | 182 | 183 | displayName: 'pip install system test requirements' | 183 | 184 | condition: and(succeeded(), eq(variables['NeedsPythonTestReqs'], 'true')) | 184 | 185 |
| |
Collapse file Copy file name to clipboardExpand all lines: gulpfile.js +36-1Lines changed: 36 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -231,7 +231,7 @@ gulp.task('verifyBundle', async () => { | 231 | 231 | gulp.task('prePublishBundle', gulp.series('webpack', 'renameSourceMaps')); | 232 | 232 | gulp.task('prePublishNonBundle', gulp.series('checkNativeDependencies', 'check-datascience-dependencies', 'compile', 'compile-webviews')); | 233 | 233 |
| 234 | | -gulp.task('installPythonLibs', async () => { | | 234 | +gulp.task('installPythonRequirements', async () => { | 235 | 235 | const requirements = fs | 236 | 236 | .readFileSync(path.join(__dirname, 'requirements.txt'), 'utf8') | 237 | 237 | .split('\n') | @@ -254,6 +254,41 @@ gulp.task('installPythonLibs', async () => { | 254 | 254 | ); | 255 | 255 | }); | 256 | 256 |
| | 257 | +// Install new PTVSD wheels for python 3.7 | | 258 | +// See https://github.com/microsoft/vscode-python/issues/7136 | | 259 | +gulp.task('installPtvsdWheels', async () => { | | 260 | + const args = ['./pythonFiles/install_ptvsd.py'] | | 261 | + const success = await spawnAsync(process.env.CI_PYTHON_PATH || 'python3', args) | | 262 | + .then(() => true) | | 263 | + .catch(ex => { | | 264 | + console.error("Failed to install new PTVSD wheels using 'python3'", ex); | | 265 | + return false; | | 266 | + }); | | 267 | + if (!success) { | | 268 | + console.info("Failed to install new PTVSD wheels using 'python3', attempting to install using 'python'"); | | 269 | + await spawnAsync('python', args.concat(requirement)).catch(ex => console.error("Failed to install PTVSD 5.0 wheels using 'python'", ex)); | | 270 | + } | | 271 | +}); | | 272 | + | | 273 | +// Install the last stable version of old PTVSD (which includes a middle layer adapter and requires ptvsd_launcher.py) | | 274 | +// until all users have migrated to the new debug adapter + new PTVSD (specified in requirements.txt) | | 275 | +// See https://github.com/microsoft/vscode-python/issues/7136 | | 276 | +gulp.task('installOldPtvsd', async () => { | | 277 | + const args = ['-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'] | | 278 | + const success = await spawnAsync(process.env.CI_PYTHON_PATH || 'python3', args) | | 279 | + .then(() => true) | | 280 | + .catch(ex => { | | 281 | + console.error("Failed to install PTVSD using 'python3'", ex); | | 282 | + return false; | | 283 | + }); | | 284 | + if (!success) { | | 285 | + console.info("Failed to install PTVSD using 'python3', attempting to install using 'python'"); | | 286 | + await spawnAsync('python', args.concat(requirement)).catch(ex => console.error("Failed to install PTVSD using 'python'", ex)); | | 287 | + } | | 288 | +}); | | 289 | + | | 290 | +gulp.task('installPythonLibs', gulp.series('installPythonRequirements', 'installOldPtvsd', 'installPtvsdWheels')); | | 291 | + | 257 | 292 | function uploadExtension(uploadBlobName) { | 258 | 293 | const azure = require('gulp-azure-storage'); | 259 | 294 | const rename = require('gulp-rename'); | |
Collapse file Copy file name to clipboardExpand all lines: pythonFiles/install_ptvsd.py +22-6Lines changed: 22 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 3 | 3 | from zipfile import ZipFile | 4 | 4 | import json | 5 | 5 | import urllib.request | | 6 | +import sys | 6 | 7 |
| 7 | | -ROOT_DIRNAME = path.dirname(path.dirname(path.dirname(path.abspath(__file__)))) | | 8 | +ROOT_DIRNAME = path.dirname(path.dirname(path.abspath(__file__))) | | 9 | +REQUIREMENTS_PATH = path.join(ROOT_DIRNAME, "requirements.txt") | 8 | 10 | PYTHONFILES_PATH = path.join(ROOT_DIRNAME, "pythonFiles", "lib", "python") | 9 | 11 | PYPI_PTVSD_URL = "https://pypi.org/pypi/ptvsd/json" | 10 | 12 |
| 11 | | -if __name__ == "__main__": | 12 | | - # Remove this when the version of PTVSD in requirements.txt gets updated. | 13 | | - # (and add code leveraging the packaging module to parse requirements.txt) in #7002 | 14 | | - ptvsd_version = "5.0.0a3" | | 13 | + | | 14 | +def install_ptvsd(): | | 15 | + # If we are in CI use the packaging module installed in PYTHONFILES_PATH. | | 16 | + if len(sys.argv) == 2 and sys.argv[1] == "--ci": | | 17 | + sys.path.insert(0, PYTHONFILES_PATH) | | 18 | + from packaging.requirements import Requirement | | 19 | + | | 20 | + with open(REQUIREMENTS_PATH, "r", encoding="utf-8") as requirements: | | 21 | + for line in requirements: | | 22 | + package_requirement = Requirement(line) | | 23 | + if package_requirement.name != "ptvsd": | | 24 | + continue | | 25 | + requirement_specifier = package_requirement.specifier | | 26 | + ptvsd_version = next(requirement_specifier.__iter__()).version | 15 | 27 |
| 16 | 28 | # Response format: https://warehouse.readthedocs.io/api-reference/json/#project | 17 | 29 | with urllib.request.urlopen(PYPI_PTVSD_URL) as response: | | 23 | 35 | # Download only if it's a 3.7 wheel. | 24 | 36 | if not wheel_info["python_version"].endswith(("37", "3.7")): | 25 | 37 | continue | 26 | | - filename = wheel_info["filename"].rpartition(".")[0] # Trim the file extension | | 38 | + filename = wheel_info["filename"].rpartition(".")[0] # Trim the file extension. | 27 | 39 | ptvsd_path = path.join(PYTHONFILES_PATH, filename) | 28 | 40 |
| 29 | 41 | with urllib.request.urlopen(wheel_info["url"]) as wheel_response: | | 38 | 50 | # Flatten the folder structure. | 39 | 51 | zip_info.filename = zip_info.filename.split(prefix)[-1] | 40 | 52 | wheel.extract(zip_info, ptvsd_path) | | 53 | + | | 54 | + | | 55 | +if __name__ == "__main__": | | 56 | + install_ptvsd() |
Collapse file Copy file name to clipboardExpand all lines: pythonFiles/ptvsd_launcher.py +5-5Lines changed: 5 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 12 | 12 |
| 13 | 13 | # Load the debugger package | 14 | 14 | try: | 15 | | - ptvs_lib_path = os.path.join(os.path.dirname(__file__), 'lib', 'python') | | 15 | + ptvsd_lib_path = os.path.join(os.path.dirname(__file__), 'lib', 'python', 'old_ptvsd') | 16 | 16 | if useCustomPtvsd: | 17 | | - sys.path.append(ptvs_lib_path) | | 17 | + sys.path.append(ptvsd_lib_path) | 18 | 18 | else: | 19 | | - sys.path.insert(0, ptvs_lib_path) | | 19 | + sys.path.insert(0, ptvsd_lib_path) | 20 | 20 | try: | 21 | 21 | import ptvsd | 22 | 22 | from ptvsd.__main__ import main | | 37 | 37 | input() | 38 | 38 | sys.exit(1) | 39 | 39 | finally: | 40 | | - if ptvs_lib_path: | 41 | | - sys.path.remove(ptvs_lib_path) | | 40 | + if ptvsd_lib_path: | | 41 | + sys.path.remove(ptvsd_lib_path) | 42 | 42 |
| 43 | 43 | main(ptvsdArgs) |
Collapse file Copy file name to clipboard +4-1Lines changed: 4 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | jedi==0.15.1 | 2 | 2 | parso==0.5.1 | 3 | 3 | isort==4.3.21 | 4 | | -ptvsd==4.3.2 | | 4 | +ptvsd==5.0.0a3 | | 5 | +pyparsing==2.4.0 | | 6 | +six==1.12.0 | | 7 | +packaging==19.1 |
|