Skip to content

Commit

Permalink
Merge pull request #1 from randomir/adapt-ci-for-leapide-fork
Browse files Browse the repository at this point in the history
CI: build vsix on leapide-* branches and PRs
  • Loading branch information
randomir authored Mar 18, 2022
2 parents 9c21f7c + 5dc999a commit 62f6ebf
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 18 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ on:
- 'release'
- 'release/*'
- 'release-*'
- 'leapide-*'
pull_request:
branches:
- main
- 'release'
- 'release/*'
- 'release-*'
- 'leapide-*'

env:
NODE_VERSION: 12.15.0
Expand All @@ -21,7 +29,7 @@ env:
jobs:
setup:
name: Set up
if: github.repository == 'microsoft/vscode-python'
#if: github.repository == 'microsoft/vscode-python'
runs-on: ubuntu-latest
defaults:
run:
Expand All @@ -43,7 +51,7 @@ jobs:
build-vsix:
name: Build VSIX
if: github.repository == 'microsoft/vscode-python'
#if: github.repository == 'microsoft/vscode-python'
needs: setup
runs-on: ubuntu-latest
steps:
Expand Down
32 changes: 16 additions & 16 deletions pythonFiles/install_debugpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
EXTENSION_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
DEBUGGER_DEST = os.path.join(EXTENSION_ROOT, "pythonFiles", "lib", "python")
DEBUGGER_PACKAGE = "debugpy"
DEBUGGER_PYTHON_VERSIONS = ("cp39",)
DEBUGGER_PYTHON_ABI_VERSIONS = ("cp39",)
DEBUGGER_VERSION = "1.5.0" # can also be "latest"


def _contains(s, parts=()):
Expand All @@ -28,35 +29,34 @@ def _get_debugger_wheel_urls(data, version):
return list(
r["url"]
for r in data["releases"][version]
if _contains(r["url"], DEBUGGER_PYTHON_VERSIONS)
if _contains(r["url"], DEBUGGER_PYTHON_ABI_VERSIONS)
)


def _download_and_extract(root, url, version):
root = os.getcwd() if root is None or root == "." else root
prefix = os.path.join("debugpy-{0}.data".format(version), "purelib")
print(url)
with url_lib.urlopen(url) as response:
# Extract only the contents of the purelib subfolder (parent folder of debugpy),
# since debugpy files rely on the presence of a 'debugpy' folder.
with zipfile.ZipFile(io.BytesIO(response.read()), "r") as wheel:
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:
if ".dist-info/" in zip_info.filename:
continue
# Normalize path for Windows, the wheel folder structure
# uses forward slashes.
normalized = os.path.normpath(zip_info.filename)
# Flatten the folder structure.
zip_info.filename = normalized.split(prefix)[-1]
wheel.extract(zip_info, root)
print("\t" + zip_info.filename)
wheel.extract(zip_info.filename, root)


def main(root):
data = _get_package_data()
latest_version = max(data["releases"].keys(), key=version_parser)

for url in _get_debugger_wheel_urls(data, latest_version):
_download_and_extract(root, url, latest_version)
if DEBUGGER_VERSION == "latest":
use_version = max(data["releases"].keys(), key=version_parser)
else:
use_version = DEBUGGER_VERSION

for url in _get_debugger_wheel_urls(data, use_version):
_download_and_extract(root, url, use_version)


if __name__ == "__main__":
Expand Down

0 comments on commit 62f6ebf

Please sign in to comment.