Repository navigation
Expand file tree
/
Copy pathaction.yml
More file actions
70 lines (65 loc) · 2.42 KB
/
Copy pathaction.yml
File metadata and controls
70 lines (65 loc) · 2.42 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
name: setup-python2
branding:
icon: "play-circle"
color: "blue"
description: setup python2 by manual compile
inputs:
config_args:
description: Add some extra argument for configure
required: false
default: ""
runs:
using: composite
steps:
- run: sudo apt-get install -y build-essential libncursesw5-dev libgdbm-dev libc6-dev zlib1g-dev libbz2-dev liblzma-dev libssl-dev libffi-dev
shell: bash
- name: get python source
run: |
echo "::group::Get & configure python2 source..."
wget https://www.python.org/ftp/python/2.7.18/Python-2.7.18.tgz -O python.tgz
tar -xvf python.tgz
echo "::endgroup::"
shell: bash
- name: Restore python2 cache
uses: actions/cache@v4
with:
path: .python2-cache
key: python2-2.7.18-${{ runner.os }}
- name: try restore cached install
run: |
mkdir -p $GITHUB_WORKSPACE/.python2-cache
if [ -f $GITHUB_WORKSPACE/.python2-cache/python2.tgz ]; then
echo "::group::Restore cached python2..."
sudo tar -xzf $GITHUB_WORKSPACE/.python2-cache/python2.tgz -C /
sudo update-alternatives --install /usr/bin/python2 python2 /opt/python2.7-2.7.18/bin/python2.7 1 || true
touch $GITHUB_WORKSPACE/.python2-cache/installed
echo "::endgroup::"
else
echo "no cached python2 found"
fi
shell: bash
- name: Compile & install (if no cache)
run: |
set -e
if [ -f $GITHUB_WORKSPACE/.python2-cache/installed ]; then
echo "Found cached installation — skipping build."
else
echo "::group::Compile&install..."
export CFLAGS="-std=c17"
cd Python-2.7.18
# install into /opt so we can cache the whole prefix
sudo mkdir -p /opt
./configure --prefix=/opt/python2.7-2.7.18 --with-pydebug ${{inputs.config_args}}
sudo make -j$(nproc) install
# create workspace cache dir and tar the prefix for caching
mkdir -p $GITHUB_WORKSPACE/.python2-cache
sudo tar -czf $GITHUB_WORKSPACE/.python2-cache/python2.tgz -C / opt/python2.7-2.7.18
sudo chown $(whoami):$(whoami) $GITHUB_WORKSPACE/.python2-cache/python2.tgz || true
touch $GITHUB_WORKSPACE/.python2-cache/installed
sudo update-alternatives --install /usr/bin/python2 python2 /opt/python2.7-2.7.18/bin/python2.7 1
echo "::endgroup::"
fi
shell: bash
- name: clean up...
run: rm -rf Python-2.7.18 && rm python.tgz
shell: bash