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}.`);
}
}
}
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