-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add cibuildwheel workflow for building pip wheels, and pip tests #583
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
5fb0d4a
294686c
a313ad4
b979374
f4c464e
9dc12b7
8035a71
1df4bf4
3aff252
5f6ebf8
09d71da
b98f232
6f47e18
ed59146
dfe55ea
6874da2
7b14ff7
761a317
444143d
90d4a8a
ad2b603
2f5e001
e1a5f2b
11b97c9
83d2bb4
e5a460c
d23880e
df4083c
8a02f55
b6a7212
6f98102
5a77be2
f871136
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| # Builds and tests the OpenSpiel wheels using cibuildwheel. | ||
| # | ||
| # Each wheel is built via the manylinux2014 pypa Docker image on Linux and | ||
| # standard MacOS X on 10.15. Each binary wheel is built only for x86_64. Basic | ||
| # API tests are run within the Docker environment that built the wheel. Full | ||
| # tests (tests that use extra dependencies such as PyTorch, JAX, Tensorflow) | ||
| # are tested in the Github Actions CI environment (Ubuntu 20.04 and Mac OS | ||
| # 10.15). | ||
| name: wheels | ||
|
|
||
| on: | ||
| # Test the wheels for each PR to ensure the PR doesn't break them. | ||
| pull_request: | ||
| branches: [ master ] | ||
| # Workflow dispatch is a way to manually trigger workflows. This will be | ||
| # used to build and test the wheels manually for releases. | ||
| workflow_dispatch: | ||
| inputs: | ||
| name: | ||
| description: 'Workflow dispatch (triggered manually)' | ||
| required: false | ||
| default: 'No name specified' | ||
|
|
||
| jobs: | ||
| build_wheels: | ||
| name: Build wheels on ${{ matrix.os }} | ||
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| matrix: | ||
| include: | ||
| - os: ubuntu-20.04 | ||
| CIBW_ENVIRONMENT: "CXX=$(which g++) OPEN_SPIEL_BUILDING_WHEEL='ON' OPEN_SPIEL_BUILD_WITH_ACPC='ON' OPEN_SPIEL_BUILD_WITH_HANABI='ON'" | ||
| CIBW_BUILD: cp36-manylinux_x86_64 cp37-manylinux_x86_64 cp38-manylinux_x86_64 cp39-manylinux_x86_64 | ||
| - os: macOS-10.15 | ||
| CIBW_ENVIRONMENT: "OPEN_SPIEL_BUILDING_WHEEL='ON' OPEN_SPIEL_BUILD_WITH_ACPC='ON' OPEN_SPIEL_BUILD_WITH_HANABI='ON'" | ||
| CIBW_BUILD: cp36-macosx_x86_64 cp37-macosx_x86_64 cp38-macosx_x86_64 cp39-macosx_x86_64 | ||
| env: | ||
| OPEN_SPIEL_BUILDING_WHEEL: ON | ||
| OPEN_SPIEL_BUILD_WITH_ACPC: ON | ||
| OPEN_SPIEL_BUILD_WITH_HANABI: ON | ||
| OS_PYTHON_VERSION: 3.9 | ||
| CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 | ||
| CIBW_BUILD: ${{ matrix.CIBW_BUILD }} | ||
| CIBW_SKIP: cp27-* pp* | ||
| CIBW_BEFORE_BUILD: python -m pip install --upgrade cmake | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These should be specified in pyproject.toml normally, then everyone who builds this from an SDist will benefit. Though I see you are running Now it might be picking up build produces from the environment, but those must be done inside |
||
| CIBW_BEFORE_TEST: python -m pip install --upgrade pip | ||
| CIBW_TEST_COMMAND: /bin/bash {project}/open_spiel/scripts/test_wheel.sh basic {project} | ||
| CIBW_ENVIRONMENT: ${{ matrix.CIBW_ENVIRONMENT }} | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - uses: actions/setup-python@v2 | ||
|
|
||
| - name: Install | ||
| run: | | ||
| pwd | ||
| uname -a | ||
| which python | ||
| which g++ | ||
| g++ --version | ||
| python --version | ||
| chmod +x install.sh | ||
| # This is needed to grab OpenSpiel dependencies. | ||
| ./install.sh | ||
| # These are necessary to install what is necessary for the build and for the full tests below. | ||
| python -m pip install --upgrade pip | ||
| python -m pip --version | ||
| python -m pip install --upgrade setuptools | ||
| python -m pip install --upgrade -r requirements.txt -q | ||
| source ./open_spiel/scripts/python_extra_deps.sh | ||
| python -m pip install --upgrade $OPEN_SPIEL_PYTHON_JAX_DEPS $OPEN_SPIEL_PYTHON_PYTORCH_DEPS $OPEN_SPIEL_PYTHON_TENSORFLOW_DEPS $OPEN_SPIEL_PYTHON_MISC_DEPS | ||
| python -m pip install twine | ||
| python -m pip install cibuildwheel==2.0.1 | ||
| - name: Build sdist | ||
| run: | | ||
| pipx run build --sdist | ||
| twine check dist/*.tar.gz | ||
|
|
||
| # Build all the wheels and run the basic tests (within the docker images) | ||
| # Basic tests are run via the CIBW_TEST_COMMAND environment variable. | ||
| - name: Build bdist_wheel and run tests | ||
| run: | | ||
| python -m cibuildwheel --output-dir wheelhouse | ||
| ls -l wheelhouse | ||
|
|
||
| # Install the built wheel and run the full tests on this host. The full | ||
| # tests include all the ones that use the machine learning libraries, | ||
| # such as Tensorflow, PyTorch, and JAX. | ||
| - name: Install bdist_wheel and full tests | ||
| run: ./open_spiel/scripts/test_wheel.sh full `pwd` | ||
|
|
||
| - uses: actions/upload-artifact@v2 | ||
| with: | ||
| path: | | ||
| dist/*.tar.gz | ||
| ./wheelhouse/*.whl | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| # 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. | ||
|
|
||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| #!/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. | ||
|
|
||
| # This file is called by the wheels workflow .github/workflows/wheels.yml. | ||
| set -e | ||
| set -x | ||
|
|
||
| if [ "$2" = "" ]; | ||
| then | ||
| echo "Usage: test_wheel <mode (full|basic)> <project main dir>" | ||
| echo "" | ||
| echo "Basic mode tests only the python functionaly (no ML libraries)" | ||
| echo "Full mode installs the extra ML libraries and the wheel. (requires Python >= 3.7 for JAX)." | ||
| exit -1 | ||
| fi | ||
|
|
||
| MODE=$1 | ||
| PROJDIR=$2 | ||
|
|
||
| uname -a | ||
|
|
||
| OS=`uname -a | awk '{print $1}'` | ||
| if [[ "$MODE" = "full" && "$OS" = "Linux" && "$OS_PYTHON_VERSION" = "3.9" ]]; then | ||
| echo "Linux detected and Python 3.9 requested. Installing Python 3.9 and setting as default." | ||
| sudo apt-get install python3.9 python3.9-dev | ||
| sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.9 1 | ||
| sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 1 | ||
| fi | ||
|
|
||
| PYBIN=${PYBIN:-"python"} | ||
| PYBIN=`which $PYBIN` | ||
|
|
||
| $PYBIN -m pip install --upgrade setuptools | ||
| $PYBIN -m pip install --upgrade -r $PROJDIR/requirements.txt -q | ||
|
|
||
| if [[ "$MODE" = "full" ]]; then | ||
| echo "Full mode. Installing ML libraries." | ||
| source $PROJDIR/open_spiel/scripts/python_extra_deps.sh | ||
| $PYBIN -m pip install --upgrade $OPEN_SPIEL_PYTHON_JAX_DEPS $OPEN_SPIEL_PYTHON_PYTORCH_DEPS $OPEN_SPIEL_PYTHON_TENSORFLOW_DEPS $OPEN_SPIEL_PYTHON_MISC_DEPS | ||
| fi | ||
|
|
||
| if [[ "$MODE" = "full" ]]; then | ||
| if [[ "$OS" = "Linux" ]]; then | ||
| ${PYBIN} -m pip install wheelhouse/open_spiel-*-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | ||
| else | ||
| ${PYBIN} -m pip install wheelhouse/open_spiel-*-cp39-cp39-macosx_10_9_x86_64.whl | ||
| fi | ||
| fi | ||
|
|
||
| export OPEN_SPIEL_BUILDING_WHEEL="ON" | ||
| export OPEN_SPIEL_BUILD_WITH_HANABI="ON" | ||
| export OPEN_SPIEL_BUILD_WITH_ACPC="ON" | ||
|
|
||
| rm -rf build && mkdir build && cd build | ||
| cmake -DPython3_EXECUTABLE=${PYBIN} $PROJDIR/open_spiel | ||
|
|
||
| NPROC="nproc" | ||
| if [[ "$OS" == "darwin"* ]]; then | ||
| NPROC="sysctl -n hw.physicalcpu" | ||
| fi | ||
|
|
||
| MAKE_NUM_PROCS=$(${NPROC}) | ||
| let TEST_NUM_PROCS=4*${MAKE_NUM_PROCS} | ||
|
|
||
| ctest -j$TEST_NUM_PROCS --output-on-failure -R "^python/*" ../open_spiel |
Uh oh!
There was an error while loading. Please reload this page.