Skip to content

Commit 72791a4

Browse files
committed
refactor: inline python runtime probe parsing flow
1 parent 8834425 commit 72791a4

1 file changed

Lines changed: 3 additions & 8 deletions

File tree

desktop/scripts/runtime-version-utils.mjs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ export const resolveExpectedRuntimeVersion = ({ rootDir }) => {
168168
);
169169
};
170170

171-
const runPythonProbe = ({ pythonExecutable, requirePipProbe }) => {
171+
const probePythonVersion = ({ pythonExecutable, requirePipProbe }) => {
172172
const probeScript = requirePipProbe
173173
? 'import sys, pip; print(sys.version_info[0], sys.version_info[1])'
174174
: 'import sys; print(sys.version_info[0], sys.version_info[1])';
@@ -196,11 +196,7 @@ const runPythonProbe = ({ pythonExecutable, requirePipProbe }) => {
196196
);
197197
}
198198

199-
return probe.stdout || '';
200-
};
201-
202-
const parseProbeVersion = (stdoutText) => {
203-
const trimmedOutput = String(stdoutText || '').trim();
199+
const trimmedOutput = String(probe.stdout || '').trim();
204200
const parts = trimmedOutput.split(/\s+/);
205201
if (parts.length < 2) {
206202
throw new Error(
@@ -224,11 +220,10 @@ export const validateRuntimePython = ({
224220
expectedRuntimeConstraint,
225221
requirePipProbe,
226222
}) => {
227-
const probeOutput = runPythonProbe({
223+
const actualVersion = probePythonVersion({
228224
pythonExecutable,
229225
requirePipProbe,
230226
});
231-
const actualVersion = parseProbeVersion(probeOutput);
232227
const expectedRuntimeVersion = expectedRuntimeConstraint.expectedRuntimeVersion;
233228
const compareResult = compareMajorMinor(actualVersion, expectedRuntimeVersion);
234229
if (expectedRuntimeConstraint.isLowerBoundRuntimeVersion) {

0 commit comments

Comments
 (0)