-
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 28 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,78 @@ | ||
| name: wheels | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: [ master ] | ||
| workflow_dispatch: | ||
| inputs: | ||
| name: | ||
| description: 'Name' | ||
| 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 | ||
| # While testing, try specific versions | ||
| # CIBW_BUILD: cp36-* cp37-* cp38-* cp39-* | ||
| CIBW_PROJECT_REQUIRES_PYTHON: ">=3.6" | ||
lanctot marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 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 | ||
| ./install.sh | ||
| python -m pip install --upgrade pip | ||
| 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 | ||
|
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. None of this should affect the cibuildwheel run. If it does, that's probably a bug - you don't want stuff built with this version of GCC, etc, inside manylinux2014, that has it's own compiler, etc. If you need it, put it in the before build variable. Join with
Collaborator
Author
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. I have added comments to explain why these are still needed. Short version: I have two set of tests now: basic and full. The 'basic' tests are run within the docker image via The 'full' tests are then run afterward (outside the docker images), by installing the wheel and running the full suite of tests (including all the Tensorflow, PyTorch, and JAX tests). So these full tests require the extra installs. |
||
| python -m pip install twine build | ||
| python -m pip install cibuildwheel==1.12.0 | ||
|
||
| - name: Build sdist | ||
| run: | | ||
| python -m build -s | ||
lanctot marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| twine check dist/*.tar.gz | ||
|
|
||
| - name: Build and test bdist_wheel | ||
| run: python -m cibuildwheel --output-dir wheelhouse | ||
|
|
||
| - name: Install and test bdist_wheel | ||
| 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,76 @@ | ||
| #!/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. | ||
| 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-0.3.1-cp39-cp39-manylinux2014_x86_64.whl | ||
| else | ||
| ${PYBIN} -m pip install wheelhouse/open_spiel-0.3.1-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.