Skip to content

Commit 470fad1

Browse files
Use pyenv to manage Python versions
PiperOrigin-RevId: 842814179
1 parent 5926f8e commit 470fad1

File tree

7 files changed

+45
-14
lines changed

7 files changed

+45
-14
lines changed

kokoro/github/ubuntu/cpu/build.sh

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,35 @@
1616
set -e
1717
set -x
1818

19-
cd "${KOKORO_ARTIFACTS_DIR}/github/gnn/"
19+
echo "Build disabled due to impossibility of using tf-nightly for testing."
20+
exit 0
21+
22+
PYENV_ROOT="/home/kbuilder/.pyenv"
23+
PYTHON_VERSION=${PYTHON_VERSION:-"3.11"}
24+
25+
echo "Installing pyenv.."
26+
git clone https://github.com/pyenv/pyenv.git "$PYENV_ROOT"
27+
export PATH="/home/kbuilder/.local/bin:$PYENV_ROOT/bin:$PATH"
28+
eval "$(pyenv init --path)"
2029

21-
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 1
30+
echo "Python setup..."
31+
pyenv install -s "$PYTHON_VERSION"
32+
pyenv global "$PYTHON_VERSION"
33+
34+
cd "${KOKORO_ARTIFACTS_DIR}/github/gnn/"
2235

23-
PYTHON_BINARY="/usr/bin/python3.9"
2436
PIP_TEST_PREFIX=bazel_pip
2537

26-
"${PYTHON_BINARY}" -m venv venv
38+
python -m venv venv
2739
source venv/bin/activate
2840

2941
# Check the python version
3042
python --version
3143
python3 --version
3244

45+
# update pip
46+
pip install --upgrade pip
47+
3348
TEST_ROOT=$(pwd)/${PIP_TEST_PREFIX}
3449
rm -rf "$TEST_ROOT"
3550
mkdir -p "$TEST_ROOT"

kokoro/github/ubuntu/cpu/build_versioned.sh

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,32 @@
1616
set -e
1717
set -x
1818

19-
cd "${KOKORO_ARTIFACTS_DIR}/github/gnn/"
19+
PYENV_ROOT="/home/kbuilder/.pyenv"
20+
PYTHON_VERSION=${PYTHON_VERSION:-"3.11"}
21+
22+
echo "Installing pyenv.."
23+
git clone https://github.com/pyenv/pyenv.git "$PYENV_ROOT"
24+
export PATH="/home/kbuilder/.local/bin:$PYENV_ROOT/bin:$PATH"
25+
eval "$(pyenv init --path)"
2026

21-
sudo apt-get install -y "python${PYTHON_VERSION}"
27+
echo "Python setup..."
28+
pyenv install -s "$PYTHON_VERSION"
29+
pyenv global "$PYTHON_VERSION"
2230

23-
# Update alternatives, taken from corresponding Keras OSS test script
24-
sudo update-alternatives --install /usr/bin/python3 python3 "/usr/bin/python$PYTHON_VERSION" 1
25-
sudo apt-get install -y python$PYTHON_VERSION-venv
31+
cd "${KOKORO_ARTIFACTS_DIR}/github/gnn/"
2632

27-
PYTHON_BINARY="/usr/bin/python${PYTHON_VERSION}"
2833
PIP_TEST_PREFIX=bazel_pip
2934

30-
"${PYTHON_BINARY}" -m venv venv
35+
python -m venv venv
3136
source venv/bin/activate
3237

3338
# Debug messages to indicate the python version
3439
python --version
3540
python3 --version
3641

42+
# update pip
43+
pip install --upgrade pip
44+
3745
TEST_ROOT=$(pwd)/${PIP_TEST_PREFIX}
3846
rm -rf "$TEST_ROOT"
3947
mkdir -p "$TEST_ROOT"

kokoro/github/ubuntu/cpu/continuous.cfg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ env_vars: {
44
key: "USE_BAZEL_VERSION"
55
value: "7.4.1" # TODO - b/390391579: Unpin once bazel 8 works.
66
}
7+
env_vars: {
8+
key: "PYTHON_VERSION"
9+
value: "3.11"
10+
}
711

812
action {
913
define_artifacts {

kokoro/github/ubuntu/cpu/oldest/continuous.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ env_vars: {
66
}
77
env_vars: {
88
key: "PYTHON_VERSION"
9-
value: "3.9"
9+
value: "3.11"
1010
}
1111
env_vars: {
1212
key: "TF_VERSION"

kokoro/github/ubuntu/cpu/oldest/presubmit.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ env_vars: {
66
}
77
env_vars: {
88
key: "PYTHON_VERSION"
9-
value: "3.9"
9+
value: "3.11"
1010
}
1111
env_vars: {
1212
key: "TF_VERSION"

kokoro/github/ubuntu/cpu/presubmit.cfg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ env_vars: {
44
key: "USE_BAZEL_VERSION"
55
value: "7.4.1" # TODO - b/390391579: Unpin once bazel 8 works.
66
}
7+
env_vars: {
8+
key: "PYTHON_VERSION"
9+
value: "3.11"
10+
}
711

812
action {
913
define_artifacts {

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def get_version():
178178
'tensorflow>=2.12.0,<3; platform_machine != "arm64" or platform_system != "Darwin"',
179179
'tensorflow-macos>=2.12.0,<3; platform_machine == "arm64" and platform_system == "Darwin"',
180180
# pylint:enable=g-line-too-long
181-
'apache-beam',
181+
'apache-beam>=2.54.0',
182182
],
183183
python_requires='>=3.9,<4',
184184
packages=find_namespace_packages(

0 commit comments

Comments
 (0)