MCPcopy Create free account
hub / github.com/appium/appium / initPython

Function initPython

packages/docutils/lib/init.ts:145–173  ·  view source on GitHub ↗
({pythonPath, dryRun = false, upgrade = false}: InitPythonOptions = {})

Source from the content-addressed store, hash-verified

143 * @param opts Options
144 */
145export async function initPython({pythonPath, dryRun = false, upgrade = false}: InitPythonOptions = {}): Promise<void> {
146 const foundPythonPath = await requirePython(pythonPath);
147
148 const args = ['-m', 'pip', 'install', '-r', REQUIREMENTS_TXT_PATH];
149 if (upgrade) {
150 args.push('--upgrade');
151 }
152 if (dryRun) {
153 dryRunLog.info(
154 'Would execute command: %s %s (environment variables: %s)',
155 foundPythonPath,
156 args.join(' '),
157 PIP_ENV_VARS,
158 );
159 } else {
160 log.debug('Executing command: %s %s (environment variables: %s)', foundPythonPath, args.join(' '), PIP_ENV_VARS);
161 log.info('Installing Python dependencies...');
162 try {
163 const result = await exec(foundPythonPath, args, {env: PIP_ENV_VARS, shell: true});
164 const {code, stdout} = result;
165 if (code !== 0) {
166 throw new DocutilsError(`Could not install Python dependencies. Reason: ${stdout}`);
167 }
168 } catch (err) {
169 throw new DocutilsError(`Could not install Python dependencies. Reason: ${(err as Error).message}`);
170 }
171 }
172 log.success('Successfully installed Python dependencies');
173}
174
175/**
176 * Main handler for `init` command.

Callers 2

initFunction · 0.85
ensurePythonDepsFunction · 0.85

Calls 4

requirePythonFunction · 0.85
pushMethod · 0.80
infoMethod · 0.65
debugMethod · 0.65

Tested by 1

ensurePythonDepsFunction · 0.68