Skip to content

Commit

Permalink
resolve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
paulacamargo25 committed Oct 17, 2023
1 parent f64c727 commit 1bac5b0
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 52 deletions.
12 changes: 3 additions & 9 deletions build/azure-pipeline.pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
35 changes: 15 additions & 20 deletions debugpy_info.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
38 changes: 15 additions & 23 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ def install_bundled_libs(session):
"--implementation",
"py",
"--no-deps",
"--upgrade",
"--require-hashes",
"--only-binary",
":all:",
"-r",
"./requirements.txt",
)
Expand All @@ -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:
Expand All @@ -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

Expand All @@ -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]}"
Expand Down Expand Up @@ -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()
Expand All @@ -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)

0 comments on commit 1bac5b0

Please sign in to comment.