Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions dist/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -82997,6 +82997,30 @@ async function useCpythonVersion(version, architecture, updateEnvironment, check
installDir = tc.find('Python', semanticVersionSpec, architecture);
}
}
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}.`);
}
}
}
Comment on lines +83011 to +83019
Copy link
Copy Markdown

@weiji14 weiji14 Mar 30, 2026

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-riscv images? I was testing this branch out using python-version: "3.13" at weiji14/cog3pio@c40e8af, but got the following error output:

Run gounthar/setup-python@cb5cf223af5f1712fe2914b9c669d2008e051022
Installed versions
  Version 3.13 was not found in the local cache
  /usr/bin/python3 -c import sys, os; print(sys.executable + "\n" + f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}" + "\n" + sys.prefix + "\n" + os.path.dirname(sys.executable))
  /usr/bin/python3
  3.12.13
  /opt/python-3.12
  /usr/bin
  Error: The version '3.13' with architecture 'riscv64' was not found for Ubuntu 24.04.
  The list of all available versions can be found here: https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json
0s

If I change to using python-version: "3.x" (see this commit), it picks up Python 3.12:

  Version 3.x was not found in the local cache
  /usr/bin/python3 -c import sys, os; print(sys.executable + "\n" + f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}" + "\n" + sys.prefix + "\n" + os.path.dirname(sys.executable))
  /usr/bin/python3
  3.12.13
  /opt/python-3.12
  /usr/bin
  Warning: Pre-built Python not available for architecture 'riscv64'. Using system Python 3.12.13 at /usr/bin/python3.
  Successfully set up CPython (3.12.13)

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?

catch {
// System Python not available, fall through to error
}
}
if (!installDir) {
const osInfo = await (0, utils_1.getOSInfo)();
const msg = [
Expand Down
28 changes: 28 additions & 0 deletions src/find-python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}.`
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed — the fallback now returns early with outputs captured directly from sys.executable, sys.prefix, and os.path.dirname(sys.executable). No longer sets installDir or relies on versionFromPath()/binDir().

);
}
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed — added !freethreaded guard. The fallback is now skipped entirely for free-threaded builds.

}
} catch {
// System Python not available, fall through to error
}
}
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The 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 (!archHasManifestEntries). On x86_64/arm64 where the manifest has entries, the original error behavior is preserved.


if (!installDir) {
const osInfo = await getOSInfo();
const msg = [
Expand Down
Loading