forked from SerVB/setup-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdownload-python.ts
More file actions
49 lines (39 loc) · 1.26 KB
/
Copy pathdownload-python.ts
File metadata and controls
49 lines (39 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import * as exec from '@actions/exec';
async function getVariable(variableName: string): Promise<string> {
let variableValue = '';
const options = {
listeners: {
stdout: (data: Buffer) => {
variableValue += data.toString();
}
}
};
await exec.exec('bash', ['-c', `echo $${variableName}`], options);
return variableValue.trim();
}
export async function downloadLinuxCpython(
version: string
): Promise<string | null> {
try {
const home = await getVariable('HOME');
await exec.exec('bash', [
'-c',
`
set -e # Any command which returns non-zero exit code will cause this shell script to exit immediately
set -x # Activate debugging to show execution details: all commands will be printed before execution
sudo apt-get install build-essential checkinstall
sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
cd $HOME
wget https://www.python.org/ftp/python/${version}/Python-${version}.tgz
tar -xvf Python-${version}.tgz
cd Python-${version}
./configure
make
sudo checkinstall -y
`
]);
return `${home}/Python-${version}`;
} catch {
return null;
}
}