[python] Fix installRequirement to use explicit version (#6272)

* [python] Fix installRequirement to use explicit version

* Remove `--upgrade`
This commit is contained in:
Steven
2021-05-24 11:41:57 -04:00
committed by GitHub
parent 93fae76f9c
commit a19fb3aa0f
2 changed files with 19 additions and 26 deletions

View File

@@ -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'],

View File

@@ -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 {