Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pin Python version at 3.11 in build workflow #67

Merged
merged 1 commit into from
Dec 6, 2023
Merged

Pin Python version at 3.11 in build workflow #67

merged 1 commit into from
Dec 6, 2023

Conversation

per1234
Copy link
Collaborator

@per1234 per1234 commented Dec 5, 2023

Python 3.12.x is incompatible with the version of the node-gyp dependency used by this project (9.4.0) (nodejs/node-gyp#2869). 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:

https://github.com/arduino/lab-micropython-editor/actions/runs/7087599689/job/19288228020#step:4:211

> 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 (nodejs/node-gyp#2923) 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 (electron/rebuild#1116) 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).


This fix has already been in use for some time in the arduino/arduino-ide repository, which suffered the same breakage: arduino/arduino-ide@97b0bc0

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).
@per1234 per1234 added the bug Something isn't working label Dec 5, 2023
@per1234
Copy link
Collaborator Author

per1234 commented Dec 6, 2023

I see that the workflow has been unnecessarily configured (pre-existing to the changes I propose here) in various ways to cause it to not run on pull requests.

That is unfortunate since it means it doesn't provide the useful automated validation for pull requests.

I modified the workflow to cause it to run in my fork. Those runs can serve as demonstrations of it working after the changes I propose here:

Copy link
Collaborator

@murilopolese murilopolese left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@per1234 per1234 merged commit 8b57764 into arduino:main Dec 6, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants