Skip to content

Commit

Permalink
Merge branch 'master' into fix_python_requirements_issue_in_dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
giogix2 committed Dec 5, 2024
2 parents 28519cb + b8225eb commit 5d17a01
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 7 deletions.
1 change: 1 addition & 0 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ jobs:
- name: Install
run: |
pwd
./open_spiel/scripts/ci_python_prechecks.sh
chmod +x install.sh
./install.sh
- name: Build and test
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
OS_PYTHON_VERSION: 3.10
CIBW_ENVIRONMENT: "CXX=$(which g++) OPEN_SPIEL_BUILDING_WHEEL='ON' OPEN_SPIEL_BUILD_WITH_ACPC='ON' OPEN_SPIEL_BUILD_WITH_HANABI='ON' OPEN_SPIEL_BUILD_WITH_ROSHAMBO='ON'"
CIBW_BUILD: cp39-manylinux_x86_64 cp310-manylinux_x86_64 cp311-manylinux_x86_64 cp312-manylinux_x86_64
- os: macOS-12
- os: macOS-13
OS_TYPE: "Darwin"
CI_PYBIN: python3.9
OS_PYTHON_VERSION: 3.9
Expand Down
27 changes: 27 additions & 0 deletions open_spiel/scripts/ci_python_prechecks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

# Copyright 2019 DeepMind Technologies Ltd. All rights reserved.
#
# 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.

# Only use for Github Actions CI!
OS=`uname -a | awk '{print $1}'`
if [[ "$OS" = "Darwin" ]]; then
# This seems to be necessary to install python via brew in Github Actions
rm -f /usr/local/bin/2to3-${OS_PYTHON_VERSION}
rm -f /usr/local/bin/idle${OS_PYTHON_VERSION}
rm -f /usr/local/bin/pydoc${OS_PYTHON_VERSION}
rm -f /usr/local/bin/python${OS_PYTHON_VERSION}
rm -f /usr/local/bin/python${OS_PYTHON_VERSION}*
fi

1 change: 0 additions & 1 deletion open_spiel/scripts/ci_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ elif [[ "$OS" = "Darwin" ]]; then
brew link --force python@${OS_PYTHON_VERSION}
fi


PYBIN=${PYBIN:-"python${OS_PYTHON_VERSION}"}
PYBIN=${PYBIN:-"python"}
PYBIN=${PYBIN:-"python3"}
Expand Down
25 changes: 20 additions & 5 deletions open_spiel/scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,24 @@ ${PYBIN} --version

MYDIR="$(dirname "$(realpath "$0")")"

# This function is only run on Github Actions!
function ci_check_install_python() {
if [[ ! "$CI" ]]; then
echo "Only run this function on Github Actions!"
exit 1
fi

# Need the trap here to make sure the return value of grep being 1 doesn't cause set -e to fail
# https://stackoverflow.com/questions/77047127/bash-capture-stderr-of-a-function-while-using-trap
trap 'ret=0; output=$(brew list --versions | grep "python ${OS_PYTHON_VERSION}") || ret="$?"; trap - RETURN' RETURN
if [[ "$output" = "" ]]; then
# The --force is needed because there seems to be a phantom installation in /usr/local/
# and errors show up for files that already exist
brew install --force "python@${OS_PYTHON_VERSION}"
fi
return 0
}

# Calling this file from the project root is not allowed,
# as all the paths here are hard-coded to be relative to it.
#
Expand Down Expand Up @@ -288,11 +306,8 @@ elif [[ "$OSTYPE" == "darwin"* ]]; then # Mac OSX
# On Github Actions, macOS comes with Python 3.9.
# We want to test multiple Python versions determined by OS_PYTHON_VERSION.
if [[ "$CI" ]]; then
# Only install the python version if it's not present. There are issues otherwise.
if [[ `brew list python@${OS_PYTHON_VERSION}; echo $?` == 0 ]]; then
brew install "python@${OS_PYTHON_VERSION}"
fi
# Uninstall Python 3.9 if we need to.
# Set brew to use the specific python version
ci_check_install_python
brew link --force --overwrite "python@${OS_PYTHON_VERSION}"
fi
`python3 -c "import tkinter" > /dev/null 2>&1` || brew install tcl-tk || echo "** Warning: failed 'brew install tcl-tk' -- continuing"
Expand Down

0 comments on commit 5d17a01

Please sign in to comment.