-
Notifications
You must be signed in to change notification settings - Fork 712
feat: fall back to system Python when pre-built binaries unavailable #1289
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -122,6 +122,34 @@ export async function useCpythonVersion( | |
| } | ||
| } | ||
|
|
||
| if (!installDir) { | ||
| // Try system Python as fallback (e.g., on architectures without pre-built binaries) | ||
| try { | ||
| const {exitCode, stdout} = await exec.getExecOutput('python3', [ | ||
| '-c', | ||
| 'import sys; print(sys.prefix)' | ||
| ]); | ||
| if (exitCode === 0) { | ||
| const systemPrefix = stdout.trim(); | ||
| const systemVersion = await exec.getExecOutput('python3', [ | ||
| '-c', | ||
| 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}")' | ||
| ]); | ||
| if ( | ||
| systemVersion.exitCode === 0 && | ||
| semver.satisfies(systemVersion.stdout.trim(), semanticVersionSpec) | ||
| ) { | ||
| installDir = systemPrefix; | ||
| core.warning( | ||
| `Pre-built Python not available for architecture '${architecture}'. Using system Python ${systemVersion.stdout.trim()} at ${systemPrefix}.` | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed — the fallback now returns early with outputs captured directly from |
||
| ); | ||
| } | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed — added |
||
| } | ||
| } catch { | ||
| // System Python not available, fall through to error | ||
| } | ||
| } | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed — tests will be added in a follow-up. The structural fixes in this push are the priority.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed — the fallback now only triggers when the manifest has zero entries for the current architecture ( |
||
|
|
||
| if (!installDir) { | ||
| const osInfo = await getOSInfo(); | ||
| const msg = [ | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this somewhat hardcoded to whatever the default Python version on the runner image is at the moment? I.e. Python 3.12 on the
ubuntu-24.04-riscvimages? I was testing this branch out usingpython-version: "3.13"at weiji14/cog3pio@c40e8af, but got the following error output:If I change to using
python-version: "3.x"(see this commit), it picks up Python 3.12:but I hit into another error with
PyO3/maturin-action(which is a separate issue 🙂). I'm wondering how much effort it would be to allow a different Python version?