( pipPath: string, uvPath: string | null, workPath: string, args: string[], targetDir?: string )
| 400 | } |
| 401 | |
| 402 | async function pipInstall( |
| 403 | pipPath: string, |
| 404 | uvPath: string | null, |
| 405 | workPath: string, |
| 406 | args: string[], |
| 407 | targetDir?: string |
| 408 | ) { |
| 409 | const target = targetDir |
| 410 | ? join(targetDir, resolveVendorDir()) |
| 411 | : resolveVendorDir(); |
| 412 | // See: https://github.com/pypa/pip/issues/4222#issuecomment-417646535 |
| 413 | // |
| 414 | // Disable installing to the Python user install directory, which is |
| 415 | // the default behavior on Debian systems and causes error: |
| 416 | // |
| 417 | // distutils.errors.DistutilsOptionError: can't combine user with |
| 418 | // prefix, exec_prefix/home, or install_(plat)base |
| 419 | process.env.PIP_USER = '0'; |
| 420 | |
| 421 | if (uvPath) { |
| 422 | const uvArgs = [ |
| 423 | 'pip', |
| 424 | 'install', |
| 425 | '--no-compile', |
| 426 | '--no-cache-dir', |
| 427 | '--target', |
| 428 | target, |
| 429 | ...filterUnsafeUvPipArgs(args), |
| 430 | ]; |
| 431 | const prettyUv = `${uvPath} ${uvArgs.join(' ')}`; |
| 432 | debug(`Running "${prettyUv}"...`); |
| 433 | try { |
| 434 | await execa(uvPath!, uvArgs, { |
| 435 | cwd: workPath, |
| 436 | env: getProtectedUvEnv(process.env, getUvCacheDir(workPath)), |
| 437 | }); |
| 438 | return; |
| 439 | } catch (err) { |
| 440 | console.log(`Failed to run "${prettyUv}", falling back to pip`); |
| 441 | debug(`error: ${err}`); |
| 442 | } |
| 443 | } |
| 444 | |
| 445 | const cmdArgs = [ |
| 446 | 'install', |
| 447 | '--disable-pip-version-check', |
| 448 | '--no-compile', |
| 449 | '--no-cache-dir', |
| 450 | '--target', |
| 451 | target, |
| 452 | ...args, |
| 453 | ]; |
| 454 | const pretty = `${pipPath} ${cmdArgs.join(' ')}`; |
| 455 | debug(`Running "${pretty}"...`); |
| 456 | try { |
| 457 | await execa(pipPath, cmdArgs, { |
| 458 | cwd: workPath, |
| 459 | }); |
no test coverage detected