in lib/setup.js [44:86]
async function installSamCli(python, version) {
const tempPath = mkdirTemp();
// Create virtual environment
const venvPath = path.join(tempPath, ".venv");
await createPythonVenv(python, venvPath);
// See https://docs.python.org/3/library/venv.html
const binDir = isWindows() ? "Scripts" : "bin";
const binPath = path.join(venvPath, binDir);
// Virtual environment Python
const pythonPath = path.join(binPath, "python");
// Ensure installation tooling is up-to-date across platforms
// setuptools and wheel needed for source and binary distributions
await exec.exec(pythonPath, ["-m", "pip", "install", "--upgrade", "pip"]);
await exec.exec(pythonPath, [
"-m",
"pip",
"install",
"--upgrade",
"setuptools",
"wheel",
]);
// Install latest compatible version
await exec.exec(pythonPath, [
"-m",
"pip",
"install",
"--upgrade",
`aws-sam-cli==${version}`,
]);
// Symlink from separate directory so only SAM CLI is added to PATH
const symlinkPath = path.join(tempPath, "bin");
fs.mkdirSync(symlinkPath);
const sam = isWindows() ? "sam.exe" : "sam";
fs.symlinkSync(path.join(binPath, sam), path.join(symlinkPath, sam));
return symlinkPath;
}