From 52db410dd8b48146d52c0a81311a5d3e4c5e4708 Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Wed, 20 Sep 2023 19:11:07 -0700 Subject: [PATCH 01/41] Update nox file and pre release --- build/azure-pipeline.pre-release.yml | 36 ++++++++++++- noxfile.py | 75 ++++++++++++++++++++++++++-- 2 files changed, 105 insertions(+), 6 deletions(-) diff --git a/build/azure-pipeline.pre-release.yml b/build/azure-pipeline.pre-release.yml index b0dc7ab1..7f18a03c 100644 --- a/build/azure-pipeline.pre-release.yml +++ b/build/azure-pipeline.pre-release.yml @@ -28,6 +28,37 @@ extends: template: azure-pipelines/extension/pre-release.yml@templates parameters: l10nSourcePaths: ./src + buildPlatforms: + - name: Linux + vsceTarget: '' + - name: Linux + packageArch: x64 + vsceTarget: linux-alpine + - name: Linux + packageArch: arm64 + vsceTarget: linux-arm64 + - name: Linux + packageArch: arm + vsceTarget: linux-armhf + - name: Linux + packageArch: x64 + vsceTarget: linux-x64 + - name: MacOS + packageArch: arm64 + vsceTarget: darwin-arm64 + - name: MacOS + packageArch: x64 + vsceTarget: darwin-x64 + - name: Windows + packageArch: arm + vsceTarget: win32-arm64 + - name: Windows + packageArch: ia32 + vsceTarget: win32-ia32 + - name: Windows + packageArch: x64 + vsceTarget: win32-x64 + buildSteps: - task: NodeTool@0 inputs: @@ -51,9 +82,10 @@ extends: displayName: Install wheel - script: python -m pip install nox - displayName: Install wheel + displayName: Install nox - - script: python -m nox --session install_bundled_libs + # update according packageArch + - script: python -m nox --session install_bundled_libs -- ${{ variables.platformName }} displayName: Install Python dependencies - script: python ./build/update_ext_version.py --for-publishing diff --git a/noxfile.py b/noxfile.py index f2133ee0..e7bdac49 100644 --- a/noxfile.py +++ b/noxfile.py @@ -1,6 +1,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. """All the action we need during build""" +from hashlib import sha256 import io import json import os @@ -11,6 +12,25 @@ import nox # pylint: disable=import-error +debugpy_urls = { + "macOS": { + "url": "https://files.pythonhosted.org/packages/b1/46/0304622c2c81215298294eba53c038c6d339b783928117687e756ade7def/debugpy-1.8.0-cp310-cp310-macosx_11_0_x86_64.whl", + "hash": "7fb95ca78f7ac43393cd0e0f2b6deda438ec7c5e47fa5d38553340897d2fbdfb" + + }, + "Windows64": { + "url": "https://files.pythonhosted.org/packages/61/ad/ba48c35ed40238f05dcf81a10dcafb743ee90f23d2d1a41ba4f030dc0626/debugpy-1.8.0-cp310-cp310-win_amd64.whl", + "hash": "5d9de202f5d42e62f932507ee8b21e30d49aae7e46d5b1dd5c908db1d7068637" + }, + "Linux": { + "url": "https://files.pythonhosted.org/packages/01/18/4be69e4b466f6452ac42b2a2cb7e581a3f1af194f1dd563d5bdabdcd8c21/debugpy-1.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", + "hash": "ef9ab7df0b9a42ed9c878afd3eaaff471fce3fa73df96022e1f5c9f8f8c87ada" + }, + "Windows32": { + "ulr": "https://files.pythonhosted.org/packages/1a/62/325e4b4b512b8b17fa10769bd7e8c64bc3e9957155c1f5eac70df7660e14/debugpy-1.8.0-cp310-cp310-win32.whl", + "hash": "a8b7a2fd27cd9f3553ac112f356ad4ca93338feadd8910277aff71ab24d8775f" + } +} def _install_bundle(session: nox.Session) -> None: session.install( @@ -25,7 +45,6 @@ def _install_bundle(session: nox.Session) -> None: "./requirements.txt", ) session.install("packaging") - _install_package(f"{os.getcwd()}/bundled/libs", "debugpy", "1.7.0") def _update_pip_packages(session: nox.Session) -> None: @@ -112,10 +131,42 @@ def _setup_template_environment(session: nox.Session) -> None: @nox.session(python="3.7") def install_bundled_libs(session): + #install debugpy by url and platform """Installs the libraries that will be bundled with the extension.""" session.install("wheel") _install_bundle(session) + if session.posargs[0] == "Linux": + download_url(f"{os.getcwd()}/bundled/libs", debugpy_urls["Linux"]) + elif session.posargs[0] == "Windows": + download_url(f"{os.getcwd()}/bundled/libs", debugpy_urls["Windows64"]) + + elif session.posargs[0] == "MacOS": + download_url(f"{os.getcwd()}/bundled/libs", debugpy_urls["MacOS"]) + else: + _install_package(f"{os.getcwd()}/bundled/libs", "debugpy") + + + + + +@nox.session() +def install_bundled_libs_win64(session): + download_url(f"{os.getcwd()}/bundled/libs", debugpy_urls["Windows64"]) + +def install_bundled_libs_win32(session): + _install_bundle(session) + download_url(f"{os.getcwd()}/bundled/libs", debugpy_urls["Windows64"]) + + +def install_bundled_libs_linux(session): + _install_bundle(session) + +def install_bundled_libs_macos(session): + _install_bundle(session) + + + @nox.session(python="3.7") def setup(session: nox.Session) -> None: @@ -145,11 +196,26 @@ def _get_pypi_package_data(package_name): def _get_urls(data, version): return list( - r["url"] for r in data["releases"][version] if _contains(r["url"], ("cp37",)) + r["url"] for r in data["releases"][version] if _contains(r["url"], ("cp310",)) ) +def download_url(root, value): + print(value["url"]) + with url_lib.urlopen(value["url"]) as response: + data = response.read() + if sha256(data) == value["hash"]: + with zipfile.ZipFile(io.BytesIO(data), "r") as wheel: + for zip_info in wheel.infolist(): + # Ignore dist info since we are merging multiple wheels + if ".dist-info/" in zip_info.filename: + continue + print("\t" + zip_info.filename) + wheel.extract(zip_info.filename, root) + + def _download_and_extract(root, url): + print("donload and extract") if "manylinux" in url or "macosx" in url or "win_amd64" in url: root = os.getcwd() if root is None or root == "." else root print(url) @@ -160,11 +226,12 @@ def _download_and_extract(root, url): # Ignore dist info since we are merging multiple wheels if ".dist-info/" in zip_info.filename: continue - print("\t" + zip_info.filename) + # print("\t" + zip_info.filename) wheel.extract(zip_info.filename, root) def _install_package(root, package_name, version="latest"): + print("package") from packaging.version import parse as version_parser data = _get_pypi_package_data(package_name) @@ -173,7 +240,7 @@ def _install_package(root, package_name, version="latest"): use_version = max(data["releases"].keys(), key=version_parser) else: use_version = version - + print(_get_urls(data, use_version)) for url in _get_urls(data, use_version): _download_and_extract(root, url) From 6c74285e934eb64568b49cad3d0c9e54fe4f900c Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Wed, 20 Sep 2023 22:08:22 -0700 Subject: [PATCH 02/41] update args --- build/azure-pipeline.pre-release.yml | 2 +- noxfile.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/build/azure-pipeline.pre-release.yml b/build/azure-pipeline.pre-release.yml index 7f18a03c..41d6a2d0 100644 --- a/build/azure-pipeline.pre-release.yml +++ b/build/azure-pipeline.pre-release.yml @@ -85,7 +85,7 @@ extends: displayName: Install nox # update according packageArch - - script: python -m nox --session install_bundled_libs -- ${{ variables.platformName }} + - script: python -m nox --session install_bundled_libs -- ${{ parameters.platformName }} ${{ parameters }} ${{ variables }} displayName: Install Python dependencies - script: python ./build/update_ext_version.py --for-publishing diff --git a/noxfile.py b/noxfile.py index e7bdac49..dc5c890a 100644 --- a/noxfile.py +++ b/noxfile.py @@ -135,6 +135,7 @@ def install_bundled_libs(session): """Installs the libraries that will be bundled with the extension.""" session.install("wheel") _install_bundle(session) + print("args: ", session.posargs) if session.posargs[0] == "Linux": download_url(f"{os.getcwd()}/bundled/libs", debugpy_urls["Linux"]) From f3a2e095b9e704c1f94773f3a9d27bfcbb3507ca Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Wed, 20 Sep 2023 22:10:06 -0700 Subject: [PATCH 03/41] update value --- build/azure-pipeline.pre-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/azure-pipeline.pre-release.yml b/build/azure-pipeline.pre-release.yml index 41d6a2d0..f78a2800 100644 --- a/build/azure-pipeline.pre-release.yml +++ b/build/azure-pipeline.pre-release.yml @@ -85,7 +85,7 @@ extends: displayName: Install nox # update according packageArch - - script: python -m nox --session install_bundled_libs -- ${{ parameters.platformName }} ${{ parameters }} ${{ variables }} + - script: python -m nox --session install_bundled_libs -- ${{ parameters }} ${{ variables }} displayName: Install Python dependencies - script: python ./build/update_ext_version.py --for-publishing From 9aa1789fbcfd110a4269b2d93874511829cafbe5 Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Wed, 20 Sep 2023 22:11:55 -0700 Subject: [PATCH 04/41] see params --- build/azure-pipeline.pre-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/azure-pipeline.pre-release.yml b/build/azure-pipeline.pre-release.yml index f78a2800..4f94a0bc 100644 --- a/build/azure-pipeline.pre-release.yml +++ b/build/azure-pipeline.pre-release.yml @@ -85,7 +85,7 @@ extends: displayName: Install nox # update according packageArch - - script: python -m nox --session install_bundled_libs -- ${{ parameters }} ${{ variables }} + - script: python -m nox --session install_bundled_libs -- ${ variables.vsceTarget } ${{ variables.packageArch }} ${{ parameters }} ${{ variables }} displayName: Install Python dependencies - script: python ./build/update_ext_version.py --for-publishing From c97c370a14853608c4207b5b599c28122175d62c Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Wed, 20 Sep 2023 22:16:48 -0700 Subject: [PATCH 05/41] echo vars --- build/azure-pipeline.pre-release.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build/azure-pipeline.pre-release.yml b/build/azure-pipeline.pre-release.yml index 4f94a0bc..d208e621 100644 --- a/build/azure-pipeline.pre-release.yml +++ b/build/azure-pipeline.pre-release.yml @@ -83,6 +83,8 @@ extends: - script: python -m pip install nox displayName: Install nox + + - script: echo $variables & echo $parameters # update according packageArch - script: python -m nox --session install_bundled_libs -- ${ variables.vsceTarget } ${{ variables.packageArch }} ${{ parameters }} ${{ variables }} From 80802916ea2235d43a509709e894a074fec85cd8 Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Wed, 20 Sep 2023 22:17:05 -0700 Subject: [PATCH 06/41] fix args --- build/azure-pipeline.pre-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/azure-pipeline.pre-release.yml b/build/azure-pipeline.pre-release.yml index d208e621..e25b621e 100644 --- a/build/azure-pipeline.pre-release.yml +++ b/build/azure-pipeline.pre-release.yml @@ -87,7 +87,7 @@ extends: - script: echo $variables & echo $parameters # update according packageArch - - script: python -m nox --session install_bundled_libs -- ${ variables.vsceTarget } ${{ variables.packageArch }} ${{ parameters }} ${{ variables }} + - script: python -m nox --session install_bundled_libs -- ${ variables.vsceTarget } ${{ variables.packageArch }} displayName: Install Python dependencies - script: python ./build/update_ext_version.py --for-publishing From 5ce94a97ffff25f66a3a7009acdea6fe2c3c092d Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Wed, 20 Sep 2023 22:31:22 -0700 Subject: [PATCH 07/41] fix args --- build/azure-pipeline.pre-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/azure-pipeline.pre-release.yml b/build/azure-pipeline.pre-release.yml index e25b621e..fa22af08 100644 --- a/build/azure-pipeline.pre-release.yml +++ b/build/azure-pipeline.pre-release.yml @@ -84,10 +84,10 @@ extends: - script: python -m pip install nox displayName: Install nox - - script: echo $variables & echo $parameters + - script: echo ${{ variables }} & echo ${{ parameters }} # update according packageArch - - script: python -m nox --session install_bundled_libs -- ${ variables.vsceTarget } ${{ variables.packageArch }} + - script: python -m nox --session install_bundled_libs -- ${{ variables.vsceTarget }} ${{ variables.packageArch }} displayName: Install Python dependencies - script: python ./build/update_ext_version.py --for-publishing From 522acaaaa5508acf5bf350a220086c8802f326b5 Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Wed, 20 Sep 2023 22:33:32 -0700 Subject: [PATCH 08/41] Fix error obj to string --- build/azure-pipeline.pre-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/azure-pipeline.pre-release.yml b/build/azure-pipeline.pre-release.yml index fa22af08..7b35119b 100644 --- a/build/azure-pipeline.pre-release.yml +++ b/build/azure-pipeline.pre-release.yml @@ -84,7 +84,7 @@ extends: - script: python -m pip install nox displayName: Install nox - - script: echo ${{ variables }} & echo ${{ parameters }} + - script: echo ${{ convertToJson(variables) }} & echo ${{ convertToJson(parameters) }} # update according packageArch - script: python -m nox --session install_bundled_libs -- ${{ variables.vsceTarget }} ${{ variables.packageArch }} From f45e4fb930846e5f414a6affe66b9fbc9b5dcacc Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Wed, 20 Sep 2023 22:40:26 -0700 Subject: [PATCH 09/41] fix command line error --- build/azure-pipeline.pre-release.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/build/azure-pipeline.pre-release.yml b/build/azure-pipeline.pre-release.yml index 7b35119b..67c3d217 100644 --- a/build/azure-pipeline.pre-release.yml +++ b/build/azure-pipeline.pre-release.yml @@ -83,11 +83,9 @@ extends: - script: python -m pip install nox displayName: Install nox - - - script: echo ${{ convertToJson(variables) }} & echo ${{ convertToJson(parameters) }} # update according packageArch - - script: python -m nox --session install_bundled_libs -- ${{ variables.vsceTarget }} ${{ variables.packageArch }} + - script: python -m nox --session install_bundled_libs -- ${{ variables.vsceTarget }} ${{ variables.packageArch }} ${{ convertToJson(variables) }} ${{ convertToJson(parameters) }} displayName: Install Python dependencies - script: python ./build/update_ext_version.py --for-publishing From 23c718c511869a030a0a8288cac04619b09a50ee Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Wed, 20 Sep 2023 23:11:37 -0700 Subject: [PATCH 10/41] update args --- build/azure-pipeline.pre-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/azure-pipeline.pre-release.yml b/build/azure-pipeline.pre-release.yml index 67c3d217..2f842c76 100644 --- a/build/azure-pipeline.pre-release.yml +++ b/build/azure-pipeline.pre-release.yml @@ -85,7 +85,7 @@ extends: displayName: Install nox # update according packageArch - - script: python -m nox --session install_bundled_libs -- ${{ variables.vsceTarget }} ${{ variables.packageArch }} ${{ convertToJson(variables) }} ${{ convertToJson(parameters) }} + - script: python -m nox --session install_bundled_libs -- ${{ parameters.buildPlatforms.name }} displayName: Install Python dependencies - script: python ./build/update_ext_version.py --for-publishing From cf22603495650a67d3757f485fff3608db774120 Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Wed, 20 Sep 2023 23:19:36 -0700 Subject: [PATCH 11/41] update how access values --- build/azure-pipeline.pre-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/azure-pipeline.pre-release.yml b/build/azure-pipeline.pre-release.yml index 2f842c76..2881561b 100644 --- a/build/azure-pipeline.pre-release.yml +++ b/build/azure-pipeline.pre-release.yml @@ -85,7 +85,7 @@ extends: displayName: Install nox # update according packageArch - - script: python -m nox --session install_bundled_libs -- ${{ parameters.buildPlatforms.name }} + - script: python -m nox --session install_bundled_libs -- $(parameters.buildPlatforms.name) $(parameters.packageArch) displayName: Install Python dependencies - script: python ./build/update_ext_version.py --for-publishing From af0fc55e91da889fb3c1905f4de790f52fd6fa39 Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Wed, 20 Sep 2023 23:35:46 -0700 Subject: [PATCH 12/41] Add args --- build/azure-pipeline.pre-release.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/build/azure-pipeline.pre-release.yml b/build/azure-pipeline.pre-release.yml index 2881561b..5ad00221 100644 --- a/build/azure-pipeline.pre-release.yml +++ b/build/azure-pipeline.pre-release.yml @@ -85,8 +85,13 @@ extends: displayName: Install nox # update according packageArch - - script: python -m nox --session install_bundled_libs -- $(parameters.buildPlatforms.name) $(parameters.packageArch) + - script: python -m nox --session install_bundled_libs displayName: Install Python dependencies + args: + [ + ${{ parameters.buildPlatforms.name }}, + ${{ parameters.packageArch }} + ] - script: python ./build/update_ext_version.py --for-publishing displayName: Update build number From 40f8f48c6191a66a8abe314e124b6f3e1f0456a2 Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Wed, 20 Sep 2023 23:55:21 -0700 Subject: [PATCH 13/41] Send arguments --- build/azure-pipeline.pre-release.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/build/azure-pipeline.pre-release.yml b/build/azure-pipeline.pre-release.yml index 5ad00221..7e05b032 100644 --- a/build/azure-pipeline.pre-release.yml +++ b/build/azure-pipeline.pre-release.yml @@ -85,13 +85,10 @@ extends: displayName: Install nox # update according packageArch - - script: python -m nox --session install_bundled_libs - displayName: Install Python dependencies - args: - [ - ${{ parameters.buildPlatforms.name }}, - ${{ parameters.packageArch }} - ] + - run: python -m nox --session install_bundled_libs + name: Install Python dependencies + shell: bash + arguments: $(parameters.buildPlatforms.name) ${{ parameters.packageArch }} - script: python ./build/update_ext_version.py --for-publishing displayName: Update build number From a1e6f0d514d9891830f1cc4da445d941e66d7bfa Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Thu, 21 Sep 2023 00:07:05 -0700 Subject: [PATCH 14/41] tried ith arguments --- build/azure-pipeline.pre-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/azure-pipeline.pre-release.yml b/build/azure-pipeline.pre-release.yml index 7e05b032..075e2ed2 100644 --- a/build/azure-pipeline.pre-release.yml +++ b/build/azure-pipeline.pre-release.yml @@ -85,7 +85,7 @@ extends: displayName: Install nox # update according packageArch - - run: python -m nox --session install_bundled_libs + - run: python -m nox --session install_bundled_libs -- ${{ parameters.packageArch }} name: Install Python dependencies shell: bash arguments: $(parameters.buildPlatforms.name) ${{ parameters.packageArch }} From 031893d023ea8439c6c6e03aa6260aa9c5d5b558 Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Thu, 21 Sep 2023 00:09:21 -0700 Subject: [PATCH 15/41] update value --- build/azure-pipeline.pre-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/azure-pipeline.pre-release.yml b/build/azure-pipeline.pre-release.yml index 075e2ed2..58ff7b80 100644 --- a/build/azure-pipeline.pre-release.yml +++ b/build/azure-pipeline.pre-release.yml @@ -85,10 +85,10 @@ extends: displayName: Install nox # update according packageArch - - run: python -m nox --session install_bundled_libs -- ${{ parameters.packageArch }} + - run: python -m nox --session install_bundled_libs -- ${{ variables.packageArch }} name: Install Python dependencies shell: bash - arguments: $(parameters.buildPlatforms.name) ${{ parameters.packageArch }} + arguments: $(parameters.buildPlatforms.name) ${{ variables.packageArch }} - script: python ./build/update_ext_version.py --for-publishing displayName: Update build number From 5bd40e64ec397879bfcf4dce5e26f8f6a83122c2 Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Thu, 21 Sep 2023 00:10:27 -0700 Subject: [PATCH 16/41] remove args extra --- build/azure-pipeline.pre-release.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/build/azure-pipeline.pre-release.yml b/build/azure-pipeline.pre-release.yml index 58ff7b80..ebffd64c 100644 --- a/build/azure-pipeline.pre-release.yml +++ b/build/azure-pipeline.pre-release.yml @@ -88,7 +88,6 @@ extends: - run: python -m nox --session install_bundled_libs -- ${{ variables.packageArch }} name: Install Python dependencies shell: bash - arguments: $(parameters.buildPlatforms.name) ${{ variables.packageArch }} - script: python ./build/update_ext_version.py --for-publishing displayName: Update build number From 05c7db97411c43e470d5b1b1184552dfaafff29f Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Thu, 21 Sep 2023 00:12:09 -0700 Subject: [PATCH 17/41] update run --- build/azure-pipeline.pre-release.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build/azure-pipeline.pre-release.yml b/build/azure-pipeline.pre-release.yml index ebffd64c..97595f99 100644 --- a/build/azure-pipeline.pre-release.yml +++ b/build/azure-pipeline.pre-release.yml @@ -85,9 +85,12 @@ extends: displayName: Install nox # update according packageArch - - run: python -m nox --session install_bundled_libs -- ${{ variables.packageArch }} + - script: python -m nox --session install_bundled_libs -- ${{ variables.packageArch }} name: Install Python dependencies shell: bash + args: $(parameters.buildPlatforms.name) ${{ variables.packageArch }} + arguments: $(parameters.buildPlatforms.name) ${{ variables.packageArch }} + - script: python ./build/update_ext_version.py --for-publishing displayName: Update build number From 45c504236feb117346c57b0805e516db4fcef900 Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Thu, 21 Sep 2023 00:19:54 -0700 Subject: [PATCH 18/41] send as env --- build/azure-pipeline.pre-release.yml | 8 +++----- noxfile.py | 3 +++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/build/azure-pipeline.pre-release.yml b/build/azure-pipeline.pre-release.yml index 97595f99..ae663191 100644 --- a/build/azure-pipeline.pre-release.yml +++ b/build/azure-pipeline.pre-release.yml @@ -86,11 +86,9 @@ extends: # update according packageArch - script: python -m nox --session install_bundled_libs -- ${{ variables.packageArch }} - name: Install Python dependencies - shell: bash - args: $(parameters.buildPlatforms.name) ${{ variables.packageArch }} - arguments: $(parameters.buildPlatforms.name) ${{ variables.packageArch }} - + displayName: Install libraries + env: + npm_config_arch: ${{ variables.packageArch }} - script: python ./build/update_ext_version.py --for-publishing displayName: Update build number diff --git a/noxfile.py b/noxfile.py index dc5c890a..6c830b01 100644 --- a/noxfile.py +++ b/noxfile.py @@ -136,6 +136,9 @@ def install_bundled_libs(session): session.install("wheel") _install_bundle(session) print("args: ", session.posargs) + print("enviro: ", os.environ.items) + print("enviro: ", os.environ) + if session.posargs[0] == "Linux": download_url(f"{os.getcwd()}/bundled/libs", debugpy_urls["Linux"]) From 94452af4a16216786ee18587ae3d6749e2417704 Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Thu, 21 Sep 2023 00:36:31 -0700 Subject: [PATCH 19/41] add to see other values --- build/azure-pipeline.pre-release.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build/azure-pipeline.pre-release.yml b/build/azure-pipeline.pre-release.yml index ae663191..e8f8c675 100644 --- a/build/azure-pipeline.pre-release.yml +++ b/build/azure-pipeline.pre-release.yml @@ -89,6 +89,8 @@ extends: displayName: Install libraries env: npm_config_arch: ${{ variables.packageArch }} + parameters: ${{ parameters }} + variables: ${{ variables }} - script: python ./build/update_ext_version.py --for-publishing displayName: Update build number From e42bdd3b345df904ebf9f352ecdab9476157964a Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Thu, 21 Sep 2023 00:43:34 -0700 Subject: [PATCH 20/41] update env variables --- build/azure-pipeline.pre-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/azure-pipeline.pre-release.yml b/build/azure-pipeline.pre-release.yml index e8f8c675..c5a99ff6 100644 --- a/build/azure-pipeline.pre-release.yml +++ b/build/azure-pipeline.pre-release.yml @@ -89,8 +89,8 @@ extends: displayName: Install libraries env: npm_config_arch: ${{ variables.packageArch }} - parameters: ${{ parameters }} - variables: ${{ variables }} + parameters: ${{ convertToJson(parameters) }} + variables: ${{ convertToJson(variables) }} - script: python ./build/update_ext_version.py --for-publishing displayName: Update build number From 7a41f9d985e55558b42216f0faaef90b6bb38db6 Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Thu, 21 Sep 2023 01:00:14 -0700 Subject: [PATCH 21/41] use VSCETARGET --- build/azure-pipeline.pre-release.yml | 5 ++--- noxfile.py | 13 +++++-------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/build/azure-pipeline.pre-release.yml b/build/azure-pipeline.pre-release.yml index c5a99ff6..4e4a086e 100644 --- a/build/azure-pipeline.pre-release.yml +++ b/build/azure-pipeline.pre-release.yml @@ -88,9 +88,8 @@ extends: - script: python -m nox --session install_bundled_libs -- ${{ variables.packageArch }} displayName: Install libraries env: - npm_config_arch: ${{ variables.packageArch }} - parameters: ${{ convertToJson(parameters) }} - variables: ${{ convertToJson(variables) }} + VSCETARGET: ${{ parameters.VSCETARGET }} + VSCETARGET2: ${{ variables.VSCETARGET }} - script: python ./build/update_ext_version.py --for-publishing displayName: Update build number diff --git a/noxfile.py b/noxfile.py index 6c830b01..d46bfaea 100644 --- a/noxfile.py +++ b/noxfile.py @@ -135,17 +135,14 @@ def install_bundled_libs(session): """Installs the libraries that will be bundled with the extension.""" session.install("wheel") _install_bundle(session) - print("args: ", session.posargs) - print("enviro: ", os.environ.items) - print("enviro: ", os.environ) + target = os.environ.get('VSCETARGET') + print("target: ", target) - - if session.posargs[0] == "Linux": + if "linux" in target: download_url(f"{os.getcwd()}/bundled/libs", debugpy_urls["Linux"]) - elif session.posargs[0] == "Windows": + elif "win32" in target: download_url(f"{os.getcwd()}/bundled/libs", debugpy_urls["Windows64"]) - - elif session.posargs[0] == "MacOS": + elif "darwin" in target: download_url(f"{os.getcwd()}/bundled/libs", debugpy_urls["MacOS"]) else: _install_package(f"{os.getcwd()}/bundled/libs", "debugpy") From 73cc6f9e1c35d87be76be0ed56ea07c4d5f1ac1e Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Thu, 21 Sep 2023 01:01:21 -0700 Subject: [PATCH 22/41] fix variable --- build/azure-pipeline.pre-release.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/build/azure-pipeline.pre-release.yml b/build/azure-pipeline.pre-release.yml index 4e4a086e..2a82f111 100644 --- a/build/azure-pipeline.pre-release.yml +++ b/build/azure-pipeline.pre-release.yml @@ -88,8 +88,7 @@ extends: - script: python -m nox --session install_bundled_libs -- ${{ variables.packageArch }} displayName: Install libraries env: - VSCETARGET: ${{ parameters.VSCETARGET }} - VSCETARGET2: ${{ variables.VSCETARGET }} + VSCETARGET: ${{ variables.VSCETARGET }} - script: python ./build/update_ext_version.py --for-publishing displayName: Update build number From 4df0ca0fe372678e6f7e3fdc43391d538eaa3632 Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Thu, 21 Sep 2023 01:11:58 -0700 Subject: [PATCH 23/41] Fix macOs error --- build/azure-pipeline.pre-release.yml | 7 ++----- noxfile.py | 6 +++--- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/build/azure-pipeline.pre-release.yml b/build/azure-pipeline.pre-release.yml index 2a82f111..18931d79 100644 --- a/build/azure-pipeline.pre-release.yml +++ b/build/azure-pipeline.pre-release.yml @@ -31,9 +31,6 @@ extends: buildPlatforms: - name: Linux vsceTarget: '' - - name: Linux - packageArch: x64 - vsceTarget: linux-alpine - name: Linux packageArch: arm64 vsceTarget: linux-arm64 @@ -85,8 +82,8 @@ extends: displayName: Install nox # update according packageArch - - script: python -m nox --session install_bundled_libs -- ${{ variables.packageArch }} - displayName: Install libraries + - script: python -m nox --session install_bundled_libs -- ${{ variables.VSCETARGET }} + displayName: Install Python dependencies env: VSCETARGET: ${{ variables.VSCETARGET }} diff --git a/noxfile.py b/noxfile.py index d46bfaea..636facc6 100644 --- a/noxfile.py +++ b/noxfile.py @@ -13,7 +13,7 @@ import nox # pylint: disable=import-error debugpy_urls = { - "macOS": { + "MacOS": { "url": "https://files.pythonhosted.org/packages/b1/46/0304622c2c81215298294eba53c038c6d339b783928117687e756ade7def/debugpy-1.8.0-cp310-cp310-macosx_11_0_x86_64.whl", "hash": "7fb95ca78f7ac43393cd0e0f2b6deda438ec7c5e47fa5d38553340897d2fbdfb" @@ -135,9 +135,9 @@ def install_bundled_libs(session): """Installs the libraries that will be bundled with the extension.""" session.install("wheel") _install_bundle(session) - target = os.environ.get('VSCETARGET') - print("target: ", target) + target = os.environ.get('VSCETARGET') + print("target:", target) if "linux" in target: download_url(f"{os.getcwd()}/bundled/libs", debugpy_urls["Linux"]) elif "win32" in target: From f5b654cd99f879e195c63da8cac0a590bfeed40b Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Thu, 21 Sep 2023 01:21:50 -0700 Subject: [PATCH 24/41] Fix lint in nox file --- noxfile.py | 41 ++++++++++------------------------------- 1 file changed, 10 insertions(+), 31 deletions(-) diff --git a/noxfile.py b/noxfile.py index 636facc6..09116424 100644 --- a/noxfile.py +++ b/noxfile.py @@ -1,7 +1,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. """All the action we need during build""" -from hashlib import sha256 +import hashlib import io import json import os @@ -15,23 +15,23 @@ debugpy_urls = { "MacOS": { "url": "https://files.pythonhosted.org/packages/b1/46/0304622c2c81215298294eba53c038c6d339b783928117687e756ade7def/debugpy-1.8.0-cp310-cp310-macosx_11_0_x86_64.whl", - "hash": "7fb95ca78f7ac43393cd0e0f2b6deda438ec7c5e47fa5d38553340897d2fbdfb" - + "hash": "7fb95ca78f7ac43393cd0e0f2b6deda438ec7c5e47fa5d38553340897d2fbdfb", }, "Windows64": { "url": "https://files.pythonhosted.org/packages/61/ad/ba48c35ed40238f05dcf81a10dcafb743ee90f23d2d1a41ba4f030dc0626/debugpy-1.8.0-cp310-cp310-win_amd64.whl", - "hash": "5d9de202f5d42e62f932507ee8b21e30d49aae7e46d5b1dd5c908db1d7068637" + "hash": "5d9de202f5d42e62f932507ee8b21e30d49aae7e46d5b1dd5c908db1d7068637", }, "Linux": { "url": "https://files.pythonhosted.org/packages/01/18/4be69e4b466f6452ac42b2a2cb7e581a3f1af194f1dd563d5bdabdcd8c21/debugpy-1.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", - "hash": "ef9ab7df0b9a42ed9c878afd3eaaff471fce3fa73df96022e1f5c9f8f8c87ada" + "hash": "ef9ab7df0b9a42ed9c878afd3eaaff471fce3fa73df96022e1f5c9f8f8c87ada", }, "Windows32": { "ulr": "https://files.pythonhosted.org/packages/1a/62/325e4b4b512b8b17fa10769bd7e8c64bc3e9957155c1f5eac70df7660e14/debugpy-1.8.0-cp310-cp310-win32.whl", - "hash": "a8b7a2fd27cd9f3553ac112f356ad4ca93338feadd8910277aff71ab24d8775f" - } + "hash": "a8b7a2fd27cd9f3553ac112f356ad4ca93338feadd8910277aff71ab24d8775f", + }, } + def _install_bundle(session: nox.Session) -> None: session.install( "-t", @@ -131,12 +131,12 @@ def _setup_template_environment(session: nox.Session) -> None: @nox.session(python="3.7") def install_bundled_libs(session): - #install debugpy by url and platform + # Install debugpy by url and platform """Installs the libraries that will be bundled with the extension.""" session.install("wheel") _install_bundle(session) - target = os.environ.get('VSCETARGET') + target = os.environ.get("VSCETARGET") print("target:", target) if "linux" in target: download_url(f"{os.getcwd()}/bundled/libs", debugpy_urls["Linux"]) @@ -147,27 +147,6 @@ def install_bundled_libs(session): else: _install_package(f"{os.getcwd()}/bundled/libs", "debugpy") - - - - -@nox.session() -def install_bundled_libs_win64(session): - download_url(f"{os.getcwd()}/bundled/libs", debugpy_urls["Windows64"]) - -def install_bundled_libs_win32(session): - _install_bundle(session) - download_url(f"{os.getcwd()}/bundled/libs", debugpy_urls["Windows64"]) - - -def install_bundled_libs_linux(session): - _install_bundle(session) - -def install_bundled_libs_macos(session): - _install_bundle(session) - - - @nox.session(python="3.7") def setup(session: nox.Session) -> None: @@ -205,7 +184,7 @@ def download_url(root, value): print(value["url"]) with url_lib.urlopen(value["url"]) as response: data = response.read() - if sha256(data) == value["hash"]: + if hashlib.sha256(data) == value["hash"]: with zipfile.ZipFile(io.BytesIO(data), "r") as wheel: for zip_info in wheel.infolist(): # Ignore dist info since we are merging multiple wheels From 4e3726ade8c1e6c54544860735233bf8db8dc57f Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Thu, 21 Sep 2023 09:59:49 -0700 Subject: [PATCH 25/41] Fix nox hash comparison --- noxfile.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/noxfile.py b/noxfile.py index 09116424..6633678b 100644 --- a/noxfile.py +++ b/noxfile.py @@ -181,10 +181,10 @@ def _get_urls(data, version): def download_url(root, value): - print(value["url"]) with url_lib.urlopen(value["url"]) as response: data = response.read() - if hashlib.sha256(data) == value["hash"]: + if hashlib.sha256(data).hexdigest() == value["hash"]: + print("Download: ", value["url"]) with zipfile.ZipFile(io.BytesIO(data), "r") as wheel: for zip_info in wheel.infolist(): # Ignore dist info since we are merging multiple wheels @@ -195,7 +195,6 @@ def download_url(root, value): def _download_and_extract(root, url): - print("donload and extract") if "manylinux" in url or "macosx" in url or "win_amd64" in url: root = os.getcwd() if root is None or root == "." else root print(url) @@ -206,12 +205,11 @@ def _download_and_extract(root, url): # Ignore dist info since we are merging multiple wheels if ".dist-info/" in zip_info.filename: continue - # print("\t" + zip_info.filename) + print("\t" + zip_info.filename) wheel.extract(zip_info.filename, root) def _install_package(root, package_name, version="latest"): - print("package") from packaging.version import parse as version_parser data = _get_pypi_package_data(package_name) @@ -220,7 +218,7 @@ def _install_package(root, package_name, version="latest"): use_version = max(data["releases"].keys(), key=version_parser) else: use_version = version - print(_get_urls(data, use_version)) + for url in _get_urls(data, use_version): _download_and_extract(root, url) From c7852dc5ddca8fd14c15b9a8be561c3578ec9ac7 Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Thu, 21 Sep 2023 10:08:15 -0700 Subject: [PATCH 26/41] Fix default value --- noxfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index 6633678b..dbc01a75 100644 --- a/noxfile.py +++ b/noxfile.py @@ -136,7 +136,7 @@ def install_bundled_libs(session): session.install("wheel") _install_bundle(session) - target = os.environ.get("VSCETARGET") + target = os.environ.get("VSCETARGET", "") print("target:", target) if "linux" in target: download_url(f"{os.getcwd()}/bundled/libs", debugpy_urls["Linux"]) From a84650b4b61118cce65dd95eb03e158310e5e0e2 Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Thu, 21 Sep 2023 10:13:07 -0700 Subject: [PATCH 27/41] Remove unnecessary code --- build/azure-pipeline.pre-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/azure-pipeline.pre-release.yml b/build/azure-pipeline.pre-release.yml index 18931d79..48766b99 100644 --- a/build/azure-pipeline.pre-release.yml +++ b/build/azure-pipeline.pre-release.yml @@ -82,7 +82,7 @@ extends: displayName: Install nox # update according packageArch - - script: python -m nox --session install_bundled_libs -- ${{ variables.VSCETARGET }} + - script: python -m nox --session install_bundled_libs displayName: Install Python dependencies env: VSCETARGET: ${{ variables.VSCETARGET }} From 5dd6b36ee9abd97e6c320d16a92887635abce53e Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Thu, 21 Sep 2023 15:21:48 -0700 Subject: [PATCH 28/41] Update platform url and debugpy version --- noxfile.py | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/noxfile.py b/noxfile.py index dbc01a75..73b74647 100644 --- a/noxfile.py +++ b/noxfile.py @@ -13,21 +13,25 @@ import nox # pylint: disable=import-error debugpy_urls = { - "MacOS": { - "url": "https://files.pythonhosted.org/packages/b1/46/0304622c2c81215298294eba53c038c6d339b783928117687e756ade7def/debugpy-1.8.0-cp310-cp310-macosx_11_0_x86_64.whl", - "hash": "7fb95ca78f7ac43393cd0e0f2b6deda438ec7c5e47fa5d38553340897d2fbdfb", + "any": { + "url": "https://files.pythonhosted.org/packages/39/2f/c8a8cfac6c7fa3d9e163a6bf46e6d27d027b7a1331028e99a6ef7fd3699d/debugpy-1.7.0-py2.py3-none-any.whl", + "hash": "f6de2e6f24f62969e0f0ef682d78c98161c4dca29e9fb05df4d2989005005502", }, - "Windows64": { - "url": "https://files.pythonhosted.org/packages/61/ad/ba48c35ed40238f05dcf81a10dcafb743ee90f23d2d1a41ba4f030dc0626/debugpy-1.8.0-cp310-cp310-win_amd64.whl", - "hash": "5d9de202f5d42e62f932507ee8b21e30d49aae7e46d5b1dd5c908db1d7068637", + "macOS": { + "url": "https://files.pythonhosted.org/packages/bd/a3/5e37ce13c7dd850b72a52be544a058ed49606ebbbf8b95b2ba3c1db5620a/debugpy-1.7.0-cp311-cp311-macosx_11_0_universal2.whl", + "hash": "538765a41198aa88cc089295b39c7322dd598f9ef1d52eaae12145c63bf9430a", }, - "Linux": { - "url": "https://files.pythonhosted.org/packages/01/18/4be69e4b466f6452ac42b2a2cb7e581a3f1af194f1dd563d5bdabdcd8c21/debugpy-1.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", - "hash": "ef9ab7df0b9a42ed9c878afd3eaaff471fce3fa73df96022e1f5c9f8f8c87ada", + "linux": { + "url": "https://files.pythonhosted.org/packages/b4/fc/087324d46dab8e21e084ce2cf670fa7e524ab5e7691692438e4987bd3ecb/debugpy-1.7.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", + "hash": "c7e8cf91f8f3f9b5fad844dd88427b85d398bda1e2a0cd65d5a21312fcbc0c6f", }, - "Windows32": { - "ulr": "https://files.pythonhosted.org/packages/1a/62/325e4b4b512b8b17fa10769bd7e8c64bc3e9957155c1f5eac70df7660e14/debugpy-1.8.0-cp310-cp310-win32.whl", - "hash": "a8b7a2fd27cd9f3553ac112f356ad4ca93338feadd8910277aff71ab24d8775f", + "win32": { + "ulr": "https://files.pythonhosted.org/packages/52/59/3591e9f709b7ee4d3a926a8903a395669cd0e0279204a94b6acccf6ed6ee/debugpy-1.7.0-cp311-cp311-win32.whl", + "hash": "18a69f8e142a716310dd0af6d7db08992aed99e2606108732efde101e7c65e2a", + }, + "win64": { + "url": "https://files.pythonhosted.org/packages/51/59/84ebd58d3e9de33a54ca8aa4532e03906e5458092dafe240264c2937a99b/debugpy-1.7.0-cp311-cp311-win_amd64.whl", + "hash": "7515a5ba5ee9bfe956685909c5f28734c1cecd4ee813523363acfe3ca824883a", }, } @@ -138,14 +142,16 @@ def install_bundled_libs(session): target = os.environ.get("VSCETARGET", "") print("target:", target) - if "linux" in target: - download_url(f"{os.getcwd()}/bundled/libs", debugpy_urls["Linux"]) - elif "win32" in target: - download_url(f"{os.getcwd()}/bundled/libs", debugpy_urls["Windows64"]) - elif "darwin" in target: - download_url(f"{os.getcwd()}/bundled/libs", debugpy_urls["MacOS"]) + if "darwin" in target: + download_url(f"{os.getcwd()}/bundled/libs", debugpy_urls["macOS"]) + elif "win32-ia32" == target: + download_url(f"{os.getcwd()}/bundled/libs", debugpy_urls["win32"]) + elif "win32-x64" == target: + download_url(f"{os.getcwd()}/bundled/libs", debugpy_urls["win64"]) + elif "linux-x64" == target: + download_url(f"{os.getcwd()}/bundled/libs", debugpy_urls["linux"]) else: - _install_package(f"{os.getcwd()}/bundled/libs", "debugpy") + download_url(f"{os.getcwd()}/bundled/libs", debugpy_urls["any"]) @nox.session(python="3.7") From b233ac5a3d2a638b12fb26d9edb4c659cb4a00e2 Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Thu, 21 Sep 2023 23:34:42 -0700 Subject: [PATCH 29/41] Fix dict key name --- noxfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index 73b74647..869a8374 100644 --- a/noxfile.py +++ b/noxfile.py @@ -26,7 +26,7 @@ "hash": "c7e8cf91f8f3f9b5fad844dd88427b85d398bda1e2a0cd65d5a21312fcbc0c6f", }, "win32": { - "ulr": "https://files.pythonhosted.org/packages/52/59/3591e9f709b7ee4d3a926a8903a395669cd0e0279204a94b6acccf6ed6ee/debugpy-1.7.0-cp311-cp311-win32.whl", + "url": "https://files.pythonhosted.org/packages/52/59/3591e9f709b7ee4d3a926a8903a395669cd0e0279204a94b6acccf6ed6ee/debugpy-1.7.0-cp311-cp311-win32.whl", "hash": "18a69f8e142a716310dd0af6d7db08992aed99e2606108732efde101e7c65e2a", }, "win64": { From 1669ea02ba9873a8b6ecb4db0581f08a23a37f1d Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Mon, 25 Sep 2023 12:21:37 -0700 Subject: [PATCH 30/41] Remove vsix for all platforms --- build/azure-pipeline.pre-release.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/build/azure-pipeline.pre-release.yml b/build/azure-pipeline.pre-release.yml index 48766b99..4111b5b9 100644 --- a/build/azure-pipeline.pre-release.yml +++ b/build/azure-pipeline.pre-release.yml @@ -29,8 +29,6 @@ extends: parameters: l10nSourcePaths: ./src buildPlatforms: - - name: Linux - vsceTarget: '' - name: Linux packageArch: arm64 vsceTarget: linux-arm64 From c9308ab0a380371764074afa79b7b91ebc9e95a2 Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Mon, 25 Sep 2023 15:28:15 -0700 Subject: [PATCH 31/41] Fix pr comments --- noxfile.py | 206 +++++++++++++---------------------------------------- 1 file changed, 50 insertions(+), 156 deletions(-) diff --git a/noxfile.py b/noxfile.py index 869a8374..0f7750b5 100644 --- a/noxfile.py +++ b/noxfile.py @@ -12,49 +12,45 @@ import nox # pylint: disable=import-error -debugpy_urls = { +DEBUGPY_WHEEL_URLS = { "any": { "url": "https://files.pythonhosted.org/packages/39/2f/c8a8cfac6c7fa3d9e163a6bf46e6d27d027b7a1331028e99a6ef7fd3699d/debugpy-1.7.0-py2.py3-none-any.whl", - "hash": "f6de2e6f24f62969e0f0ef682d78c98161c4dca29e9fb05df4d2989005005502", + "hash": ( + "sha256", + "f6de2e6f24f62969e0f0ef682d78c98161c4dca29e9fb05df4d2989005005502", + ), }, "macOS": { "url": "https://files.pythonhosted.org/packages/bd/a3/5e37ce13c7dd850b72a52be544a058ed49606ebbbf8b95b2ba3c1db5620a/debugpy-1.7.0-cp311-cp311-macosx_11_0_universal2.whl", - "hash": "538765a41198aa88cc089295b39c7322dd598f9ef1d52eaae12145c63bf9430a", + "sha256": ( + "sha256", + "538765a41198aa88cc089295b39c7322dd598f9ef1d52eaae12145c63bf9430a", + ), }, "linux": { "url": "https://files.pythonhosted.org/packages/b4/fc/087324d46dab8e21e084ce2cf670fa7e524ab5e7691692438e4987bd3ecb/debugpy-1.7.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", - "hash": "c7e8cf91f8f3f9b5fad844dd88427b85d398bda1e2a0cd65d5a21312fcbc0c6f", + "hash": ( + "sha256", + "c7e8cf91f8f3f9b5fad844dd88427b85d398bda1e2a0cd65d5a21312fcbc0c6f", + ), }, "win32": { "url": "https://files.pythonhosted.org/packages/52/59/3591e9f709b7ee4d3a926a8903a395669cd0e0279204a94b6acccf6ed6ee/debugpy-1.7.0-cp311-cp311-win32.whl", - "hash": "18a69f8e142a716310dd0af6d7db08992aed99e2606108732efde101e7c65e2a", + "hash": ( + "sha256", + "18a69f8e142a716310dd0af6d7db08992aed99e2606108732efde101e7c65e2a", + ), }, "win64": { "url": "https://files.pythonhosted.org/packages/51/59/84ebd58d3e9de33a54ca8aa4532e03906e5458092dafe240264c2937a99b/debugpy-1.7.0-cp311-cp311-win_amd64.whl", - "hash": "7515a5ba5ee9bfe956685909c5f28734c1cecd4ee813523363acfe3ca824883a", + "hash": ( + "sha256", + "7515a5ba5ee9bfe956685909c5f28734c1cecd4ee813523363acfe3ca824883a", + ), }, } -def _install_bundle(session: nox.Session) -> None: - session.install( - "-t", - "./bundled/libs", - "--no-cache-dir", - "--implementation", - "py", - "--no-deps", - "--upgrade", - "-r", - "./requirements.txt", - ) - session.install("packaging") - - -def _update_pip_packages(session: nox.Session) -> None: - session.run("pip-compile", "--generate-hashes", "--upgrade", "./requirements.in") - - @nox.session() def lint(session: nox.Session) -> None: """Runs linter and formatter checks on python files.""" @@ -81,152 +77,50 @@ def tests(session: nox.Session) -> None: session.run("npm", "run", "test") -def _get_package_data(package): - json_uri = f"https://registry.npmjs.org/{package}" - with url_lib.urlopen(json_uri) as response: - return json.loads(response.read()) - - -def _update_npm_packages(session: nox.Session) -> None: - pinned = { - "vscode-languageclient", - "@types/vscode", - "@types/node", - } - package_json_path = pathlib.Path(__file__).parent / "package.json" - package_json = json.loads(package_json_path.read_text(encoding="utf-8")) - - for package in package_json["dependencies"]: - if package not in pinned: - data = _get_package_data(package) - latest = "^" + data["dist-tags"]["latest"] - package_json["dependencies"][package] = latest - - for package in package_json["devDependencies"]: - if package not in pinned: - data = _get_package_data(package) - latest = "^" + data["dist-tags"]["latest"] - package_json["devDependencies"][package] = latest - - # Ensure engine matches the package - if ( - package_json["engines"]["vscode"] - != package_json["devDependencies"]["@types/vscode"] - ): - print( - "Please check VS Code engine version and @types/vscode version in package.json." - ) - - new_package_json = json.dumps(package_json, indent=4) - # JSON dumps uses \n for line ending on all platforms by default - if not new_package_json.endswith("\n"): - new_package_json += "\n" - package_json_path.write_text(new_package_json, encoding="utf-8") - - session.run("npm", "audit", "fix", external=True) - session.run("npm", "install", external=True) - - -def _setup_template_environment(session: nox.Session) -> None: - session.install("wheel", "pip-tools") - _update_pip_packages(session) - _install_bundle(session) - - -@nox.session(python="3.7") +@nox.session() def install_bundled_libs(session): - # Install debugpy by url and platform + # Install debugpy by URL and platform """Installs the libraries that will be bundled with the extension.""" session.install("wheel") - _install_bundle(session) + session.install( + "-t", + "./bundled/libs", + "--no-cache-dir", + "--implementation", + "py", + "--no-deps", + "--upgrade", + "-r", + "./requirements.txt", + ) + session.install("packaging") target = os.environ.get("VSCETARGET", "") print("target:", target) if "darwin" in target: - download_url(f"{os.getcwd()}/bundled/libs", debugpy_urls["macOS"]) + download_url(DEBUGPY_WHEEL_URLS["macOS"]) elif "win32-ia32" == target: - download_url(f"{os.getcwd()}/bundled/libs", debugpy_urls["win32"]) + download_url(DEBUGPY_WHEEL_URLS["win32"]) elif "win32-x64" == target: - download_url(f"{os.getcwd()}/bundled/libs", debugpy_urls["win64"]) + download_url(DEBUGPY_WHEEL_URLS["win64"]) elif "linux-x64" == target: - download_url(f"{os.getcwd()}/bundled/libs", debugpy_urls["linux"]) + download_url(DEBUGPY_WHEEL_URLS["linux"]) else: - download_url(f"{os.getcwd()}/bundled/libs", debugpy_urls["any"]) + download_url(DEBUGPY_WHEEL_URLS["any"]) -@nox.session(python="3.7") -def setup(session: nox.Session) -> None: - """Sets up the extension for development.""" - _setup_template_environment(session) - - -@nox.session() -def update_packages(session: nox.Session) -> None: - """Update pip and npm packages.""" - session.install("wheel", "pip-tools") - _update_pip_packages(session) - _update_npm_packages(session) - - -def _contains(s, parts=()): - return any(p for p in parts if p in s) - - -def _get_pypi_package_data(package_name): - json_uri = "https://pypi.org/pypi/{0}/json".format(package_name) - # Response format: https://warehouse.readthedocs.io/api-reference/json/#project - # Release metadata format: https://github.com/pypa/interoperability-peps/blob/master/pep-0426-core-metadata.rst - with url_lib.urlopen(json_uri) as response: - return json.loads(response.read()) - - -def _get_urls(data, version): - return list( - r["url"] for r in data["releases"][version] if _contains(r["url"], ("cp310",)) - ) - - -def download_url(root, value): +def download_url(value): with url_lib.urlopen(value["url"]) as response: data = response.read() - if hashlib.sha256(data).hexdigest() == value["hash"]: - print("Download: ", value["url"]) - with zipfile.ZipFile(io.BytesIO(data), "r") as wheel: - for zip_info in wheel.infolist(): - # Ignore dist info since we are merging multiple wheels - if ".dist-info/" in zip_info.filename: - continue - print("\t" + zip_info.filename) - wheel.extract(zip_info.filename, root) - - -def _download_and_extract(root, url): - if "manylinux" in url or "macosx" in url or "win_amd64" in url: - root = os.getcwd() if root is None or root == "." else root - print(url) - with url_lib.urlopen(url) as response: - data = response.read() - with zipfile.ZipFile(io.BytesIO(data), "r") as wheel: - for zip_info in wheel.infolist(): - # Ignore dist info since we are merging multiple wheels - if ".dist-info/" in zip_info.filename: - continue - print("\t" + zip_info.filename) - wheel.extract(zip_info.filename, root) - - -def _install_package(root, package_name, version="latest"): - from packaging.version import parse as version_parser - - data = _get_pypi_package_data(package_name) - - if version == "latest": - use_version = max(data["releases"].keys(), key=version_parser) - else: - use_version = version - - for url in _get_urls(data, use_version): - _download_and_extract(root, url) + if hashlib.sha256(data).hexdigest() != value["hash"][1]: + raise Exception("Failed hash verification for {}.".format(value["url"])) + print("Download: ", value["url"]) + with zipfile.ZipFile(io.BytesIO(data), "r") as wheel: + for zip_info in wheel.infolist(): + print("\t" + zip_info.filename) + wheel.extract( + zip_info.filename, pathlib.Path.cwd() / "bundled" / "libs" + ) @nox.session() From 2b43b10e80ba49cdc0640dde31cc0947364acdde Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Mon, 25 Sep 2023 16:10:00 -0700 Subject: [PATCH 32/41] fix download function --- noxfile.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/noxfile.py b/noxfile.py index 0f7750b5..66e2263a 100644 --- a/noxfile.py +++ b/noxfile.py @@ -17,12 +17,12 @@ "url": "https://files.pythonhosted.org/packages/39/2f/c8a8cfac6c7fa3d9e163a6bf46e6d27d027b7a1331028e99a6ef7fd3699d/debugpy-1.7.0-py2.py3-none-any.whl", "hash": ( "sha256", - "f6de2e6f24f62969e0f0ef682d78c98161c4dca29e9fb05df4d2989005005502", + "f6de2e6f24f62969e0f0ef682d78c98161c4dca29e9fb05df4d298900500550", ), }, "macOS": { "url": "https://files.pythonhosted.org/packages/bd/a3/5e37ce13c7dd850b72a52be544a058ed49606ebbbf8b95b2ba3c1db5620a/debugpy-1.7.0-cp311-cp311-macosx_11_0_universal2.whl", - "sha256": ( + "hash": ( "sha256", "538765a41198aa88cc089295b39c7322dd598f9ef1d52eaae12145c63bf9430a", ), @@ -79,7 +79,6 @@ def tests(session: nox.Session) -> None: @nox.session() def install_bundled_libs(session): - # Install debugpy by URL and platform """Installs the libraries that will be bundled with the extension.""" session.install("wheel") session.install( @@ -112,15 +111,15 @@ def install_bundled_libs(session): def download_url(value): with url_lib.urlopen(value["url"]) as response: data = response.read() - if hashlib.sha256(data).hexdigest() != value["hash"][1]: - raise Exception("Failed hash verification for {}.".format(value["url"])) + hash_algorithm, hash_digest = value["hash"] + if hashlib.new(hash_algorithm, data).hexdigest() != hash_digest: + raise ValueError("Failed hash verification for {}.".format(value["url"])) print("Download: ", value["url"]) with zipfile.ZipFile(io.BytesIO(data), "r") as wheel: + libs_dir = pathlib.Path.cwd() / "bundled" / "libs" for zip_info in wheel.infolist(): print("\t" + zip_info.filename) - wheel.extract( - zip_info.filename, pathlib.Path.cwd() / "bundled" / "libs" - ) + wheel.extract(zip_info.filename, libs_dir) @nox.session() From 4f7e706e654c61ff90eaeaa56309821f534976fd Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Mon, 25 Sep 2023 16:21:43 -0700 Subject: [PATCH 33/41] fix hash code --- noxfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index 66e2263a..de6f1b3f 100644 --- a/noxfile.py +++ b/noxfile.py @@ -17,7 +17,7 @@ "url": "https://files.pythonhosted.org/packages/39/2f/c8a8cfac6c7fa3d9e163a6bf46e6d27d027b7a1331028e99a6ef7fd3699d/debugpy-1.7.0-py2.py3-none-any.whl", "hash": ( "sha256", - "f6de2e6f24f62969e0f0ef682d78c98161c4dca29e9fb05df4d298900500550", + "f6de2e6f24f62969e0f0ef682d78c98161c4dca29e9fb05df4d2989005005502", ), }, "macOS": { From cf2ed03db22542fbc817f996ae36d9894838ef95 Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Tue, 26 Sep 2023 17:27:47 -0700 Subject: [PATCH 34/41] Read from json pypypackage --- noxfile.py | 41 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/noxfile.py b/noxfile.py index de6f1b3f..4c10a71d 100644 --- a/noxfile.py +++ b/noxfile.py @@ -97,21 +97,27 @@ def install_bundled_libs(session): target = os.environ.get("VSCETARGET", "") print("target:", target) if "darwin" in target: - download_url(DEBUGPY_WHEEL_URLS["macOS"]) + # download_url(DEBUGPY_WHEEL_URLS["macOS"]) + _get_debugpy_url("1.7.0", "macosx") elif "win32-ia32" == target: - download_url(DEBUGPY_WHEEL_URLS["win32"]) + _get_debugpy_url("1.7.0", "win32") + # download_url(DEBUGPY_WHEEL_URLS["win32"]) elif "win32-x64" == target: - download_url(DEBUGPY_WHEEL_URLS["win64"]) + _get_debugpy_url("1.7.0", "win_amd64") + # download_url(DEBUGPY_WHEEL_URLS["win64"]) elif "linux-x64" == target: - download_url(DEBUGPY_WHEEL_URLS["linux"]) + _get_debugpy_url("1.7.0", "manylinux") + # download_url(DEBUGPY_WHEEL_URLS["linux"]) else: - download_url(DEBUGPY_WHEEL_URLS["any"]) + _get_debugpy_url("1.7.0") + # download_url(DEBUGPY_WHEEL_URLS["any"]) def download_url(value): with url_lib.urlopen(value["url"]) as response: data = response.read() hash_algorithm, hash_digest = value["hash"] + print(hash_digest) if hashlib.new(hash_algorithm, data).hexdigest() != hash_digest: raise ValueError("Failed hash verification for {}.".format(value["url"])) print("Download: ", value["url"]) @@ -143,3 +149,28 @@ def update_build_number(session: nox.Session) -> None: session.log(f"Updating version from {package_json['version']} to {version}") package_json["version"] = version package_json_path.write_text(json.dumps(package_json, indent=4), encoding="utf-8") + +def _get_pypi_package_data(package_name): + json_uri = "https://pypi.org/pypi/{0}/json".format(package_name) + # Response format: https://warehouse.readthedocs.io/api-reference/json/#project + # Release metadata format: https://github.com/pypa/interoperability-peps/blob/master/pep-0426-core-metadata.rst + with url_lib.urlopen(json_uri) as response: + return json.loads(response.read()) + +def _get_debugpy_url(version="latest", platform="none-any", cp="cp311"): + from packaging.version import parse as version_parser + + data = _get_pypi_package_data('debugpy') + + if version == "latest": + use_version = max(data["releases"].keys(), key=version_parser) + else: + use_version = version + + data = list( + {"url": r["url"], "hash": ("sha256", r["digests"]["sha256"])} for r in data["releases"][use_version] if _contains(r["filename"], ("{}-{}".format(cp, platform),)) + )[0] + download_url(data) + +def _contains(s, parts=()): + return any(p for p in parts if p in s) From 5c95bd32e979633e6629050792e230894215a514 Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Tue, 10 Oct 2023 14:12:34 -0700 Subject: [PATCH 35/41] add json file and session that creates it --- debugpy_platforms.json | 37 +++++++++++++++++++++++++++++++++++++ noxfile.py | 30 ++++++++++++++++++++++++++---- 2 files changed, 63 insertions(+), 4 deletions(-) create mode 100644 debugpy_platforms.json diff --git a/debugpy_platforms.json b/debugpy_platforms.json new file mode 100644 index 00000000..abf5dd7b --- /dev/null +++ b/debugpy_platforms.json @@ -0,0 +1,37 @@ +{ + "macos": { + "url": "https://files.pythonhosted.org/packages/bd/a3/5e37ce13c7dd850b72a52be544a058ed49606ebbbf8b95b2ba3c1db5620a/debugpy-1.7.0-cp311-cp311-macosx_11_0_universal2.whl", + "hash": [ + "sha256", + "538765a41198aa88cc089295b39c7322dd598f9ef1d52eaae12145c63bf9430a" + ] + }, + "win32": { + "url": "https://files.pythonhosted.org/packages/52/59/3591e9f709b7ee4d3a926a8903a395669cd0e0279204a94b6acccf6ed6ee/debugpy-1.7.0-cp311-cp311-win32.whl", + "hash": [ + "sha256", + "18a69f8e142a716310dd0af6d7db08992aed99e2606108732efde101e7c65e2a" + ] + }, + "win64": { + "url": "https://files.pythonhosted.org/packages/51/59/84ebd58d3e9de33a54ca8aa4532e03906e5458092dafe240264c2937a99b/debugpy-1.7.0-cp311-cp311-win_amd64.whl", + "hash": [ + "sha256", + "7515a5ba5ee9bfe956685909c5f28734c1cecd4ee813523363acfe3ca824883a" + ] + }, + "linux": { + "url": "https://files.pythonhosted.org/packages/b4/fc/087324d46dab8e21e084ce2cf670fa7e524ab5e7691692438e4987bd3ecb/debugpy-1.7.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", + "hash": [ + "sha256", + "c7e8cf91f8f3f9b5fad844dd88427b85d398bda1e2a0cd65d5a21312fcbc0c6f" + ] + }, + "any": { + "url": "https://files.pythonhosted.org/packages/39/2f/c8a8cfac6c7fa3d9e163a6bf46e6d27d027b7a1331028e99a6ef7fd3699d/debugpy-1.7.0-py2.py3-none-any.whl", + "hash": [ + "sha256", + "f6de2e6f24f62969e0f0ef682d78c98161c4dca29e9fb05df4d2989005005502" + ] + } +} \ No newline at end of file diff --git a/noxfile.py b/noxfile.py index 4c10a71d..05a7d49d 100644 --- a/noxfile.py +++ b/noxfile.py @@ -157,7 +157,7 @@ def _get_pypi_package_data(package_name): with url_lib.urlopen(json_uri) as response: return json.loads(response.read()) -def _get_debugpy_url(version="latest", platform="none-any", cp="cp311"): +def _get_debugpy_info(version="latest", platform="none-any", cp="cp311"): from packaging.version import parse as version_parser data = _get_pypi_package_data('debugpy') @@ -167,10 +167,32 @@ def _get_debugpy_url(version="latest", platform="none-any", cp="cp311"): else: use_version = version - data = list( - {"url": r["url"], "hash": ("sha256", r["digests"]["sha256"])} for r in data["releases"][use_version] if _contains(r["filename"], ("{}-{}".format(cp, platform),)) + try: + return list( + {"url": r["url"], "hash": ("sha256", r["digests"]["sha256"])} for r in data["releases"][use_version] if _contains(r["url"], ("{}-{}".format(cp, platform),)) )[0] - download_url(data) + except: + return list( + {"url": r["url"], "hash": ("sha256", r["digests"]["sha256"])} for r in data["releases"][use_version] if _contains(r["url"], ("{}-{}".format("py3", platform),)) + )[0] + + +@nox.session() +def create_debugpy_json(session: nox.Session, version="1.7.0", cp="cp311"): + platforms = [("macos", "macosx"), ("win32", "win32"), ("win64", "win_amd64"), ("linux", "manylinux"),("any", "none-any")] + + debugpy_platforms_json_path = pathlib.Path(__file__).parent / "debugpy_platforms.json" + debugpy_platforms = json.loads(debugpy_platforms_json_path.read_text(encoding="utf-8")) + for p, id in platforms: + print(p, id) + data = _get_debugpy_info(version, id, cp) + print(data) + debugpy_platforms[p] = data + # debugpy_platforms[] + debugpy_platforms_json_path.write_text(json.dumps(debugpy_platforms, indent=4), encoding="utf-8") + + + def _contains(s, parts=()): return any(p for p in parts if p in s) From f64c727ee6d97e4b327a61d27c78879cb399eb22 Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Wed, 11 Oct 2023 12:28:19 -0700 Subject: [PATCH 36/41] Reformat nox file --- debugpy_platforms.json => debugpy_info.json | 2 +- noxfile.py | 107 +++++++------------- 2 files changed, 37 insertions(+), 72 deletions(-) rename debugpy_platforms.json => debugpy_info.json (99%) diff --git a/debugpy_platforms.json b/debugpy_info.json similarity index 99% rename from debugpy_platforms.json rename to debugpy_info.json index abf5dd7b..3c5bb7b8 100644 --- a/debugpy_platforms.json +++ b/debugpy_info.json @@ -1,5 +1,5 @@ { - "macos": { + "macOS": { "url": "https://files.pythonhosted.org/packages/bd/a3/5e37ce13c7dd850b72a52be544a058ed49606ebbbf8b95b2ba3c1db5620a/debugpy-1.7.0-cp311-cp311-macosx_11_0_universal2.whl", "hash": [ "sha256", diff --git a/noxfile.py b/noxfile.py index 05a7d49d..f5db57c7 100644 --- a/noxfile.py +++ b/noxfile.py @@ -12,44 +12,6 @@ import nox # pylint: disable=import-error -DEBUGPY_WHEEL_URLS = { - "any": { - "url": "https://files.pythonhosted.org/packages/39/2f/c8a8cfac6c7fa3d9e163a6bf46e6d27d027b7a1331028e99a6ef7fd3699d/debugpy-1.7.0-py2.py3-none-any.whl", - "hash": ( - "sha256", - "f6de2e6f24f62969e0f0ef682d78c98161c4dca29e9fb05df4d2989005005502", - ), - }, - "macOS": { - "url": "https://files.pythonhosted.org/packages/bd/a3/5e37ce13c7dd850b72a52be544a058ed49606ebbbf8b95b2ba3c1db5620a/debugpy-1.7.0-cp311-cp311-macosx_11_0_universal2.whl", - "hash": ( - "sha256", - "538765a41198aa88cc089295b39c7322dd598f9ef1d52eaae12145c63bf9430a", - ), - }, - "linux": { - "url": "https://files.pythonhosted.org/packages/b4/fc/087324d46dab8e21e084ce2cf670fa7e524ab5e7691692438e4987bd3ecb/debugpy-1.7.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", - "hash": ( - "sha256", - "c7e8cf91f8f3f9b5fad844dd88427b85d398bda1e2a0cd65d5a21312fcbc0c6f", - ), - }, - "win32": { - "url": "https://files.pythonhosted.org/packages/52/59/3591e9f709b7ee4d3a926a8903a395669cd0e0279204a94b6acccf6ed6ee/debugpy-1.7.0-cp311-cp311-win32.whl", - "hash": ( - "sha256", - "18a69f8e142a716310dd0af6d7db08992aed99e2606108732efde101e7c65e2a", - ), - }, - "win64": { - "url": "https://files.pythonhosted.org/packages/51/59/84ebd58d3e9de33a54ca8aa4532e03906e5458092dafe240264c2937a99b/debugpy-1.7.0-cp311-cp311-win_amd64.whl", - "hash": ( - "sha256", - "7515a5ba5ee9bfe956685909c5f28734c1cecd4ee813523363acfe3ca824883a", - ), - }, -} - @nox.session() def lint(session: nox.Session) -> None: @@ -94,30 +56,27 @@ def install_bundled_libs(session): ) session.install("packaging") + debugpy_info_json_path = pathlib.Path(__file__).parent / "debugpy_info.json" + debugpy_info = json.loads(debugpy_info_json_path.read_text(encoding="utf-8")) + target = os.environ.get("VSCETARGET", "") print("target:", target) if "darwin" in target: - # download_url(DEBUGPY_WHEEL_URLS["macOS"]) - _get_debugpy_url("1.7.0", "macosx") + download_url(debugpy_info["macOS"]) elif "win32-ia32" == target: - _get_debugpy_url("1.7.0", "win32") - # download_url(DEBUGPY_WHEEL_URLS["win32"]) + download_url(debugpy_info["win32"]) elif "win32-x64" == target: - _get_debugpy_url("1.7.0", "win_amd64") - # download_url(DEBUGPY_WHEEL_URLS["win64"]) + download_url(debugpy_info["win64"]) elif "linux-x64" == target: - _get_debugpy_url("1.7.0", "manylinux") - # download_url(DEBUGPY_WHEEL_URLS["linux"]) + download_url(debugpy_info["linux"]) else: - _get_debugpy_url("1.7.0") - # download_url(DEBUGPY_WHEEL_URLS["any"]) + download_url(debugpy_info["any"]) def download_url(value): with url_lib.urlopen(value["url"]) as response: data = response.read() hash_algorithm, hash_digest = value["hash"] - print(hash_digest) if hashlib.new(hash_algorithm, data).hexdigest() != hash_digest: raise ValueError("Failed hash verification for {}.".format(value["url"])) print("Download: ", value["url"]) @@ -150,17 +109,19 @@ def update_build_number(session: nox.Session) -> None: package_json["version"] = version package_json_path.write_text(json.dumps(package_json, indent=4), encoding="utf-8") + def _get_pypi_package_data(package_name): json_uri = "https://pypi.org/pypi/{0}/json".format(package_name) # Response format: https://warehouse.readthedocs.io/api-reference/json/#project # Release metadata format: https://github.com/pypa/interoperability-peps/blob/master/pep-0426-core-metadata.rst with url_lib.urlopen(json_uri) as response: return json.loads(response.read()) - + + def _get_debugpy_info(version="latest", platform="none-any", cp="cp311"): from packaging.version import parse as version_parser - data = _get_pypi_package_data('debugpy') + data = _get_pypi_package_data("debugpy") if version == "latest": use_version = max(data["releases"].keys(), key=version_parser) @@ -169,30 +130,34 @@ def _get_debugpy_info(version="latest", platform="none-any", cp="cp311"): try: return list( - {"url": r["url"], "hash": ("sha256", r["digests"]["sha256"])} for r in data["releases"][use_version] if _contains(r["url"], ("{}-{}".format(cp, platform),)) - )[0] - + {"url": r["url"], "hash": ("sha256", r["digests"]["sha256"])} + for r in data["releases"][use_version] + if _contains(r["url"], ("{}-{}".format(cp, platform),)) + )[0] + except: - return list( - {"url": r["url"], "hash": ("sha256", r["digests"]["sha256"])} for r in data["releases"][use_version] if _contains(r["url"], ("{}-{}".format("py3", platform),)) - )[0] - + return list( + {"url": r["url"], "hash": ("sha256", r["digests"]["sha256"])} + for r in data["releases"][use_version] + if _contains(r["url"], ("{}-{}".format("py3", platform),)) + )[0] + @nox.session() def create_debugpy_json(session: nox.Session, version="1.7.0", cp="cp311"): - platforms = [("macos", "macosx"), ("win32", "win32"), ("win64", "win_amd64"), ("linux", "manylinux"),("any", "none-any")] - - debugpy_platforms_json_path = pathlib.Path(__file__).parent / "debugpy_platforms.json" - debugpy_platforms = json.loads(debugpy_platforms_json_path.read_text(encoding="utf-8")) - for p, id in platforms: - print(p, id) - data = _get_debugpy_info(version, id, cp) - print(data) - debugpy_platforms[p] = data - # debugpy_platforms[] - debugpy_platforms_json_path.write_text(json.dumps(debugpy_platforms, indent=4), encoding="utf-8") - - + platforms = [ + ("macOS", "macosx"), + ("win32", "win32"), + ("win64", "win_amd64"), + ("linux", "manylinux"), + ("any", "none-any"), + ] + debugpy_info_json_path = pathlib.Path(__file__).parent / "debugpy_info.json" + debugpy_info = {p: _get_debugpy_info(version, id, cp) for p, id in platforms} + debugpy_info_json_path.write_text( + json.dumps(debugpy_info, indent=4), encoding="utf-8" + ) + def _contains(s, parts=()): return any(p for p in parts if p in s) From 1bac5b03984ca35c947382c7f7510ec71e332c8c Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Tue, 17 Oct 2023 00:42:02 -0700 Subject: [PATCH 37/41] resolve comments --- build/azure-pipeline.pre-release.yml | 12 +++------ debugpy_info.json | 35 +++++++++++-------------- noxfile.py | 38 +++++++++++----------------- 3 files changed, 33 insertions(+), 52 deletions(-) diff --git a/build/azure-pipeline.pre-release.yml b/build/azure-pipeline.pre-release.yml index 4111b5b9..b343a3ef 100644 --- a/build/azure-pipeline.pre-release.yml +++ b/build/azure-pipeline.pre-release.yml @@ -70,17 +70,11 @@ extends: - script: npm ci displayName: Install NPM dependencies - - script: python -m pip install -U pip - displayName: Upgrade pip - - - script: python -m pip install wheel - displayName: Install wheel - - - script: python -m pip install nox - displayName: Install nox + -install wheel script: python -m pip install -U pip pipx wheel + displayName: Update pip, install pipx and install wheel # update according packageArch - - script: python -m nox --session install_bundled_libs + - script: pipx run nox --session install_bundled_libs displayName: Install Python dependencies env: VSCETARGET: ${{ variables.VSCETARGET }} diff --git a/debugpy_info.json b/debugpy_info.json index 3c5bb7b8..76266411 100644 --- a/debugpy_info.json +++ b/debugpy_info.json @@ -1,37 +1,32 @@ { "macOS": { "url": "https://files.pythonhosted.org/packages/bd/a3/5e37ce13c7dd850b72a52be544a058ed49606ebbbf8b95b2ba3c1db5620a/debugpy-1.7.0-cp311-cp311-macosx_11_0_universal2.whl", - "hash": [ - "sha256", - "538765a41198aa88cc089295b39c7322dd598f9ef1d52eaae12145c63bf9430a" - ] + "hash": { + "sha256": "538765a41198aa88cc089295b39c7322dd598f9ef1d52eaae12145c63bf9430a" + } }, "win32": { "url": "https://files.pythonhosted.org/packages/52/59/3591e9f709b7ee4d3a926a8903a395669cd0e0279204a94b6acccf6ed6ee/debugpy-1.7.0-cp311-cp311-win32.whl", - "hash": [ - "sha256", - "18a69f8e142a716310dd0af6d7db08992aed99e2606108732efde101e7c65e2a" - ] + "hash": { + "sha256": "18a69f8e142a716310dd0af6d7db08992aed99e2606108732efde101e7c65e2a" + } }, "win64": { "url": "https://files.pythonhosted.org/packages/51/59/84ebd58d3e9de33a54ca8aa4532e03906e5458092dafe240264c2937a99b/debugpy-1.7.0-cp311-cp311-win_amd64.whl", - "hash": [ - "sha256", - "7515a5ba5ee9bfe956685909c5f28734c1cecd4ee813523363acfe3ca824883a" - ] + "hash": { + "sha256": "7515a5ba5ee9bfe956685909c5f28734c1cecd4ee813523363acfe3ca824883a" + } }, "linux": { "url": "https://files.pythonhosted.org/packages/b4/fc/087324d46dab8e21e084ce2cf670fa7e524ab5e7691692438e4987bd3ecb/debugpy-1.7.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", - "hash": [ - "sha256", - "c7e8cf91f8f3f9b5fad844dd88427b85d398bda1e2a0cd65d5a21312fcbc0c6f" - ] + "hash": { + "sha256": "c7e8cf91f8f3f9b5fad844dd88427b85d398bda1e2a0cd65d5a21312fcbc0c6f" + } }, "any": { "url": "https://files.pythonhosted.org/packages/39/2f/c8a8cfac6c7fa3d9e163a6bf46e6d27d027b7a1331028e99a6ef7fd3699d/debugpy-1.7.0-py2.py3-none-any.whl", - "hash": [ - "sha256", - "f6de2e6f24f62969e0f0ef682d78c98161c4dca29e9fb05df4d2989005005502" - ] + "hash": { + "sha256": "f6de2e6f24f62969e0f0ef682d78c98161c4dca29e9fb05df4d2989005005502" + } } } \ No newline at end of file diff --git a/noxfile.py b/noxfile.py index f5db57c7..9e3aad14 100644 --- a/noxfile.py +++ b/noxfile.py @@ -50,7 +50,9 @@ def install_bundled_libs(session): "--implementation", "py", "--no-deps", - "--upgrade", + "--require-hashes", + "--only-binary", + ":all:", "-r", "./requirements.txt", ) @@ -73,11 +75,13 @@ def install_bundled_libs(session): download_url(debugpy_info["any"]) -def download_url(value): +def download_url(value, hash_algorithm="sha256"): with url_lib.urlopen(value["url"]) as response: data = response.read() - hash_algorithm, hash_digest = value["hash"] - if hashlib.new(hash_algorithm, data).hexdigest() != hash_digest: + if ( + hashlib.new(hash_algorithm, data).hexdigest() + != value["hash"][hash_algorithm] + ): raise ValueError("Failed hash verification for {}.".format(value["url"])) print("Download: ", value["url"]) with zipfile.ZipFile(io.BytesIO(data), "r") as wheel: @@ -90,7 +94,7 @@ def download_url(value): @nox.session() def update_build_number(session: nox.Session) -> None: """Updates build number for the extension.""" - if len(session.posargs) == 0: + if not len(session.posargs): session.log("No updates to package version") return @@ -99,7 +103,7 @@ def update_build_number(session: nox.Session) -> None: package_json = json.loads(package_json_path.read_text(encoding="utf-8")) - parts = re.split("\\.|-", package_json["version"]) + parts = re.split(r"\.|-", package_json["version"]) major, minor = parts[:2] version = f"{major}.{minor}.{session.posargs[0]}" @@ -128,19 +132,11 @@ def _get_debugpy_info(version="latest", platform="none-any", cp="cp311"): else: use_version = version - try: - return list( - {"url": r["url"], "hash": ("sha256", r["digests"]["sha256"])} - for r in data["releases"][use_version] - if _contains(r["url"], ("{}-{}".format(cp, platform),)) - )[0] - - except: - return list( - {"url": r["url"], "hash": ("sha256", r["digests"]["sha256"])} - for r in data["releases"][use_version] - if _contains(r["url"], ("{}-{}".format("py3", platform),)) - )[0] + return list( + {"url": r["url"], "hash": {"sha256": r["digests"]["sha256"]}} + for r in data["releases"][use_version] + if f"{cp}-{platform}" in r["url"] or f"py3-{platform}" in r["url"] + )[0] @nox.session() @@ -157,7 +153,3 @@ def create_debugpy_json(session: nox.Session, version="1.7.0", cp="cp311"): debugpy_info_json_path.write_text( json.dumps(debugpy_info, indent=4), encoding="utf-8" ) - - -def _contains(s, parts=()): - return any(p for p in parts if p in s) From ebf13d88966156ce44f896fced58f6270ffaf1f7 Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Tue, 17 Oct 2023 00:48:16 -0700 Subject: [PATCH 38/41] fix lint error --- build/azure-pipeline.pre-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/azure-pipeline.pre-release.yml b/build/azure-pipeline.pre-release.yml index b343a3ef..7c57ae20 100644 --- a/build/azure-pipeline.pre-release.yml +++ b/build/azure-pipeline.pre-release.yml @@ -70,7 +70,7 @@ extends: - script: npm ci displayName: Install NPM dependencies - -install wheel script: python -m pip install -U pip pipx wheel + - script: python -m pip install -U pip pipx wheel displayName: Update pip, install pipx and install wheel # update according packageArch From 95a257bf6870a19d400e9bd24e760bd6634793b4 Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Tue, 17 Oct 2023 00:57:39 -0700 Subject: [PATCH 39/41] update pipeline --- build/azure-pipeline.pre-release.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/build/azure-pipeline.pre-release.yml b/build/azure-pipeline.pre-release.yml index 7c57ae20..c7daba55 100644 --- a/build/azure-pipeline.pre-release.yml +++ b/build/azure-pipeline.pre-release.yml @@ -70,8 +70,11 @@ extends: - script: npm ci displayName: Install NPM dependencies - - script: python -m pip install -U pip pipx wheel - displayName: Update pip, install pipx and install wheel + - script: python -m pip install -U pip + displayName: Upgrade pip + + - script: python -m pip install wheel nox + displayName: Install wheel and nox # update according packageArch - script: pipx run nox --session install_bundled_libs From b436f0bd6db82cac2bed9b8efe5ba64bb04d9544 Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Tue, 17 Oct 2023 01:54:07 -0700 Subject: [PATCH 40/41] fix build error --- build/azure-pipeline.pre-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/azure-pipeline.pre-release.yml b/build/azure-pipeline.pre-release.yml index c7daba55..6c085735 100644 --- a/build/azure-pipeline.pre-release.yml +++ b/build/azure-pipeline.pre-release.yml @@ -77,7 +77,7 @@ extends: displayName: Install wheel and nox # update according packageArch - - script: pipx run nox --session install_bundled_libs + - script: python -m nox --session install_bundled_libs displayName: Install Python dependencies env: VSCETARGET: ${{ variables.VSCETARGET }} From 9070859343f53379c3ddb9ed5e8344850223373e Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Wed, 18 Oct 2023 14:27:59 -0700 Subject: [PATCH 41/41] dont hardcode the hash --- noxfile.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/noxfile.py b/noxfile.py index 9e3aad14..80bcfa92 100644 --- a/noxfile.py +++ b/noxfile.py @@ -75,14 +75,15 @@ def install_bundled_libs(session): download_url(debugpy_info["any"]) -def download_url(value, hash_algorithm="sha256"): +def download_url(value): with url_lib.urlopen(value["url"]) as response: data = response.read() - if ( - hashlib.new(hash_algorithm, data).hexdigest() - != value["hash"][hash_algorithm] - ): + hash_algorithm, hash_value = [ + (key, value) for key, value in value["hash"].items() + ][0] + if hashlib.new(hash_algorithm, data).hexdigest() != hash_value: raise ValueError("Failed hash verification for {}.".format(value["url"])) + print("Download: ", value["url"]) with zipfile.ZipFile(io.BytesIO(data), "r") as wheel: libs_dir = pathlib.Path.cwd() / "bundled" / "libs"