From e7fbe4b2c6e942e45e1aad1e6711f6dcc49f9fec Mon Sep 17 00:00:00 2001 From: per1234 Date: Tue, 5 Dec 2023 08:19:31 -0800 Subject: [PATCH] Pin Python version at 3.11 in build workflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Python 3.12.x is incompatible with the version of the node-gyp dependency used by this project (9.4.0). Previously, the workflow used whichever version of Python was pre-installed on the GitHub Actions runner machine. The Python version was recently updated from 3.11.5 to 3.12.0 in the macOS runner, which caused the workflow to start failing: ``` > electron-rebuild - Searching dependency tree Traceback (most recent call last): File "/Users/runner/work/lab-micropython-editor/lab-micropython-editor/node_modules/node-gyp/gyp/gyp_main.py", line 42, in import gyp # noqa: E402 ^^^^^^^^^^ File "/Users/runner/work/lab-micropython-editor/lab-micropython-editor/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 9, in import gyp.input File "/Users/runner/work/lab-micropython-editor/lab-micropython-editor/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 19, in from distutils.version import StrictVersion ModuleNotFoundError: No module named 'distutils' ✖ Rebuild Failed An unhandled error occurred inside electron-rebuild node-gyp failed to rebuild '/Users/runner/work/lab-micropython-editor/lab-micropython-editor/node_modules/@serialport/bindings-cpp'. For more information, rerun with the DEBUG environment variable set to "electron-rebuild". Error: `gyp` failed with exit code: 1 ``` The incompatibility has been fixed in node-gyp and released in version 10.0.0, but it is not trivial to update node-gyp because it is a transitive dependency of the direct electron-rebuild dependency, which specifies node-gyp@^9.0.0. For this reason, the chosen solution is to configure the "GitHub Actions" workflow to use the compatible Python 3.11.x. At such time as a new version of electron-rebuild is released that indicates compatibility with node-gyp@^10.0.0 and the project's dependencies are updated, pinning to Python 3.11.x specifically will no longer be needed. However, it will likely be best practices to leave this actions/setup-python step in the workflow even after that since it allows the version of Python used for the build to be controlled by the project maintainers, and for consistency across all the runner machines (at this time, the preinstalled version on the Linux machine is 3.10.12 and the Windows machine 3.7.9). --- .github/workflows/build.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 350ced5..3f5df7f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -38,10 +38,10 @@ jobs: node-version: '16' registry-url: 'https://registry.npmjs.org' - # - name: Install Python 2.7 - # uses: actions/setup-python@v3 - # with: - # python-version: '2.7' + - name: Install Python 3.x + uses: actions/setup-python@v4 + with: + python-version: '3.11.x' - name: Package shell: bash