Commit 4c28503
committed
Restore support for external platform Python package dependencies
Although Arduino boards platforms traditionally have bundled all dependencies, there are some cases where the user will
need to use a preceding workflow step to install external dependencies in the GitHub Actions runner environment.
Since it is a "composite action", this is feasible and was previously supported. However, support for Python package
dependencies is more complicated due to the action script running in a Python virtual environment which isolates it from
packages installed globally. The workaround for this was to use the `--system-site-packages` flag in the venv invocation
that created the action's Python virtual environment. This approach introduced a requirement that the project Python
version match the minor version series of the runner system Python. That requirement was violated when the workflow's
runner was updated to `ubuntu-22.04` which has system Python 3.10.x, whereas the action used 3.8. The breakage went
unnoticed because the sole Python package platform dependency in real world usage, pyserial, had been preinstalled in
the runner's Linux package manager "site-packages" folder, which caused it to be installed in the action's virtual
environment even though it would not have if depending on the user installation of the package as was previously the
case.
The solution is to use a path configuration file to add the path of the system Python's "user site-packages" folder
(where package dependencies installed via the workflow are located) to the module search paths used by the action's
Python virtual environment.
This is actually superior to the previous approach of using the `--system-site-packages` flag in the venv invocation
(this flag is also supported by pipx and Poetry) because:
- It avoids the chance of interference with the virtual environment through the unnecessary introduction of the global
"site-packages" path into the module search paths along with the intended introduction of the "user site-packages"
path.
- It allows any version of Python to be used to run the action, rather than being forced to use the same minor version
series as the runner's system Python (which can be updated at any time and also depends on the workflow configuration)1 parent 042dd4a commit 4c28503
3 files changed
+46
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
212 | 212 | | |
213 | 213 | | |
214 | 214 | | |
215 | | - | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
216 | 220 | | |
217 | 221 | | |
218 | 222 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
52 | 59 | | |
53 | 60 | | |
54 | 61 | | |
| |||
67 | 74 | | |
68 | 75 | | |
69 | 76 | | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
70 | 94 | | |
71 | 95 | | |
72 | 96 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
0 commit comments