mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-10 21:07:48 +00:00
[python] Fix installRequirement to use explicit version (#6272)
* [python] Fix installRequirement to use explicit version * Remove `--upgrade`
This commit is contained in:
@@ -86,6 +86,7 @@ export const build = async ({
|
||||
|
||||
await installRequirement({
|
||||
dependency: 'werkzeug',
|
||||
version: '1.0.1',
|
||||
workPath,
|
||||
meta,
|
||||
});
|
||||
@@ -109,6 +110,7 @@ export const build = async ({
|
||||
const tempDir = await getWriteableDirectory();
|
||||
await installRequirement({
|
||||
dependency: 'pipfile-requirements',
|
||||
version: '0.3.0',
|
||||
workPath: tempDir,
|
||||
meta,
|
||||
args: ['--no-warn-script-location'],
|
||||
|
||||
@@ -61,39 +61,28 @@ async function pipInstall(workPath: string, args: string[]) {
|
||||
// distutils.errors.DistutilsOptionError: can't combine user with
|
||||
// prefix, exec_prefix/home, or install_(plat)base
|
||||
process.env.PIP_USER = '0';
|
||||
debug(
|
||||
`Running "pip install --disable-pip-version-check --target ${target} --upgrade ${args.join(
|
||||
' '
|
||||
)}"...`
|
||||
);
|
||||
const cmdArgs = [
|
||||
'install',
|
||||
'--disable-pip-version-check',
|
||||
'--target',
|
||||
target,
|
||||
...args,
|
||||
];
|
||||
debug(`Running "pip3 ${cmdArgs.join(' ')}"...`);
|
||||
try {
|
||||
await execa(
|
||||
pipPath,
|
||||
[
|
||||
'install',
|
||||
'--disable-pip-version-check',
|
||||
'--target',
|
||||
target,
|
||||
'--upgrade',
|
||||
...args,
|
||||
],
|
||||
{
|
||||
cwd: workPath,
|
||||
stdio: 'pipe',
|
||||
}
|
||||
);
|
||||
await execa(pipPath, cmdArgs, {
|
||||
cwd: workPath,
|
||||
stdio: 'pipe',
|
||||
});
|
||||
} catch (err) {
|
||||
console.log(
|
||||
`Failed to run "pip install --disable-pip-version-check --target ${target} --upgrade ${args.join(
|
||||
' '
|
||||
)}"...`
|
||||
);
|
||||
console.log(`Failed to run "pip3 ${cmdArgs.join(' ')}"`);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
interface InstallRequirementArg {
|
||||
dependency: string;
|
||||
version: string;
|
||||
workPath: string;
|
||||
meta: Meta;
|
||||
args?: string[];
|
||||
@@ -101,6 +90,7 @@ interface InstallRequirementArg {
|
||||
|
||||
export async function installRequirement({
|
||||
dependency,
|
||||
version,
|
||||
workPath,
|
||||
meta,
|
||||
args = [],
|
||||
@@ -111,7 +101,8 @@ export async function installRequirement({
|
||||
);
|
||||
return;
|
||||
}
|
||||
await pipInstall(workPath, [dependency, ...args]);
|
||||
const exact = `${dependency}==${version}`;
|
||||
await pipInstall(workPath, [exact, ...args]);
|
||||
}
|
||||
|
||||
interface InstallRequirementsFileArg {
|
||||
|
||||
Reference in New Issue
Block a user