Skip to content

Commit

Permalink
manually install python if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
shubha-rajan committed Dec 12, 2022
1 parent 03cb6ee commit aef927c
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 3 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/sample-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,10 @@ jobs:
service_account: ${{ secrets.SERVICE_ACCOUNT }}

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
run: |
if python -V | grep -q -L '3.10'; then
./examples/java/install_python.sh
fi
- name: 'Set up Cloud SDK'
uses: 'google-github-actions/[email protected]'
Expand Down
47 changes: 47 additions & 0 deletions examples/java/install_python.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#! /bin/bash
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# `-e` enables the script to automatically fail when a command fails
set -ex

sudo apt update

# Install dependencies
sudo apt install -y \
build-essential \
zlib1g-dev \
libncurses5-dev \
libgdbm-dev libnss3-dev \
libssl-dev \
libreadline-dev \
libffi-dev \
libsqlite3-dev \
wget \
libbz2-dev

# Download Source Code
wget https://www.python.org/ftp/python/3.10.0/Python-3.10.0.tgz
tar -xvf Python-3.10.0.tgz

# Build from source
cd Python-3.10.0
sudo ./configure --enable-optimizations
sudo make -j "$(nproc)"
sudo make altinstall


update-alternatives --install /usr/bin/python python /usr/local/bin/python3.10 1
update-alternatives --install /usr/bin/pip pip /usr/local/bin/pip3.10 1
python --version

0 comments on commit aef927c

Please sign in to comment.