Skip to content

Commit e7fbe4b

Browse files
committed
Pin Python version at 3.11 in build workflow
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 <module> 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 <module> 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 <module> 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).
1 parent 9dedd05 commit e7fbe4b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

.github/workflows/build.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ jobs:
3838
node-version: '16'
3939
registry-url: 'https://registry.npmjs.org'
4040

41-
# - name: Install Python 2.7
42-
# uses: actions/setup-python@v3
43-
# with:
44-
# python-version: '2.7'
41+
- name: Install Python 3.x
42+
uses: actions/setup-python@v4
43+
with:
44+
python-version: '3.11.x'
4545

4646
- name: Package
4747
shell: bash

0 commit comments

Comments
 (0)