From 6c06eae6ca790de695be37cff3a79bd01124d729 Mon Sep 17 00:00:00 2001 From: Chad Smith Date: Sun, 29 Aug 2021 21:31:21 -0700 Subject: [PATCH] build gdbgui as python executable (pex) (#402) --- .github/workflows/build_executable.yml | 5 +++-- CHANGELOG.md | 2 ++ docs/index.md | 1 + make_executable.py | 10 +--------- noxfile.py | 22 ++++++++++++++++++++++ 5 files changed, 29 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build_executable.yml b/.github/workflows/build_executable.yml index eea282a9..7f0bb34f 100644 --- a/.github/workflows/build_executable.yml +++ b/.github/workflows/build_executable.yml @@ -36,7 +36,8 @@ jobs: nox --non-interactive --session build_executable_${{ matrix.buildname }} - name: Upload ${{ matrix.buildname }} executable # if: github.ref == 'refs/heads/master' - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v2 with: name: gdbgui_${{ matrix.buildname }} - path: ./executable/${{ matrix.buildname }} + path: | + ./build/executable diff --git a/CHANGELOG.md b/CHANGELOG.md index 8403ef21..9dc39e2e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ This release is focused mostly on Python 3.9 compatibility and updating dependencies - Support only Python 3.9 (though other Python versions may still work) +- Build gdbgui as a [pex](https://pypi.org/project/pex/) executable. + - These are executable Python environments that are self-contained with the exception of requiring a specific Python version installed in the environment running the executable. The pex executables should have better compatibility than PyInstaller executables, which sometimes have missing shared libraries depending on the operating system. - Use only the threading async model for flask-socketio. No longer support gevent or eventlet. - [bugfix] Catch exception if gdb used in tty window crashes instead of gdbgui crashing along with it - Disable pagination in gdb tty by default. It can be turned back on with `set pagination off`. diff --git a/docs/index.md b/docs/index.md index 53dbbe70..a963ba5c 100644 --- a/docs/index.md +++ b/docs/index.md @@ -85,4 +85,5 @@ gdbgui is distributed through ## Contact +https://chadsmith.dev chadsmith.software@gmail.com diff --git a/make_executable.py b/make_executable.py index 32cf502e..4d548152 100644 --- a/make_executable.py +++ b/make_executable.py @@ -13,14 +13,6 @@ import logging logging.basicConfig(level=logging.INFO) -if platform.startswith("linux"): - platform_dir = "linux" -elif platform.startswith("darwin"): - platform_dir = "mac" -elif platform == "win32": - platform_dir = "windows" -else: - raise Exception("Unknown platform") def write_spec_with_gdbgui_version_in_name(spec_path, binary_name): @@ -92,7 +84,7 @@ def generate_md5(binary: Path, output_file: Path): def main(): binary_name = "gdbgui_%s" % __version__ spec_path = "gdbgui_pyinstaller.spec" - distpath = (Path("executable") / platform_dir).resolve() + distpath = Path("build/executable").resolve() extension = ".exe" if platform == "win32" else "" binary_path = Path(distpath) / f"{binary_name}{extension}" diff --git a/noxfile.py b/noxfile.py index f185b546..f003a3d3 100644 --- a/noxfile.py +++ b/noxfile.py @@ -2,6 +2,7 @@ from pathlib import Path from sys import platform +import hashlib import nox # type: ignore @@ -162,6 +163,7 @@ def build_executable_current_platform(session): session.run("yarn", "build", external=True) session.install(".", "PyInstaller>=4.5, <4.6") session.run("python", "make_executable.py") + session.notify("build_pex") @nox.session(reuse_venv=True) @@ -183,3 +185,23 @@ def build_executable_windows(session): if not platform.startswith("win32"): raise Exception(f"Unexpected platform {platform}") session.notify("build_executable_current_platform") + + +@nox.session(python=python) +def build_pex(session): + """Builds a pex of gdbgui""" + # NOTE: frontend must be built before running this + session.install("pex==2.1.45") + pex_path = Path("build/executable/gdbgui.pex") + session.run( + "pex", + ".", + "-c", + "gdbgui", + "-o", + str(pex_path), + external=True, + ) + checksum = hashlib.md5(pex_path.read_bytes()).hexdigest() + with open(f"{pex_path}.md5", "w+") as f: + f.write(checksum + "\n")