Skip to content

Commit 16aa0b3

Browse files
authored
Merge pull request #31 from mcdonnnj/improvement/adjust_python_installation_on_linux_runners
Only install Python from `deadsnakes` on Ubuntu versions prior to 22.04
2 parents e80931f + 7cf72c7 commit 16aa0b3

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

monitor/setup.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,16 @@ if [ "$RUNNER_OS" = "macOS" ]; then
112112

113113
elif [ "$RUNNER_OS" = "Linux" ]; then
114114

115+
# ubuntu 22.04 and later install python 3.10 or later by default
116+
python_package="python3"
117+
115118
# install python 3.10, otherwise ubuntu 20.04 installs 3.8 and we won't get the latest mitmproxy with important bug fixes
116-
sudo add-apt-repository ppa:deadsnakes/ppa -y
117-
sudo apt install -y python3.10-venv
119+
if (( "$(lsb_release --short --release | cut --delimiter='.' --fields=1)" < 22 )); then
120+
sudo add-apt-repository ppa:deadsnakes/ppa -y
121+
python_package="python3.10"
122+
fi
123+
124+
sudo apt install -y "$python_package"-venv
118125

119126
# create mitmproxyuser, otherwise proxy won't intercept local trafic from the same user
120127
sudo useradd --create-home mitmproxyuser
@@ -125,7 +132,7 @@ elif [ "$RUNNER_OS" = "Linux" ]; then
125132
git clone -b main https://github.com/mitmproxy/mitmproxy.git && \
126133
cd mitmproxy && \
127134
git checkout 5353df5f1eeaf5fc36d9b5f7024199c888aed116 && \
128-
python3.10 -m venv venv && \
135+
"$(command -v python3.10 || command -v python3)" -m venv venv && \
129136
venv/bin/pip install -e ".[dev]" '
130137

131138
sudo cp mitm_plugin.py /home/mitmproxyuser/mitm_plugin.py

0 commit comments

Comments
 (0)