[envpool] Add macOS install, test, and wheel support #299
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release PyPI Wheel | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - v* | |
| pull_request: | |
| jobs: | |
| macos-wheel: | |
| if: ${{ github.event_name == 'pull_request' }} | |
| runs-on: macos-14 | |
| timeout-minutes: 60 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: ["3.11", "3.12", "3.13"] | |
| env: | |
| HOMEBREW_NO_AUTO_UPDATE: "1" | |
| steps: | |
| - uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version: "1.22" | |
| - uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: "17" | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install macOS dependencies | |
| run: | | |
| brew install swig qt@5 | |
| echo "BAZEL_RULES_QT_DIR=$(brew --prefix qt@5)" >> "$GITHUB_ENV" | |
| - name: Install bazelisk | |
| run: | | |
| go install github.com/bazelbuild/bazelisk@latest | |
| echo "$HOME/go/bin" >> "$GITHUB_PATH" | |
| - name: Build macOS wheel | |
| run: | | |
| rm -rf dist | |
| make RELEASE_PYTHON=${{ matrix.python-version }} bazel-release | |
| - name: Verify wheel install | |
| run: | | |
| python3 -m pip install dist/*.whl --force-reinstall | |
| tmpdir="$(mktemp -d)" | |
| cd "$tmpdir" | |
| python3 - <<'PY' | |
| import envpool | |
| env = envpool.make("CartPole-v1", env_type="gym", num_envs=1) | |
| obs, info = env.reset() | |
| print(envpool.__version__) | |
| print(type(obs).__name__, getattr(obs, "shape", None)) | |
| print(sorted(info.keys())) | |
| PY | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: macos-wheel-${{ matrix.python-version }} | |
| path: dist/*.whl | |
| if-no-files-found: error | |
| release: | |
| if: ${{ github.event_name == 'push' }} | |
| runs-on: ubuntu-latest | |
| container: quay.io/pypa/manylinux_2_28_x86_64 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: ["3.11", "3.12", "3.13"] | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Install build dependencies | |
| run: | | |
| dnf install -y git curl wget zsh gcc gcc-c++ make tmux golang java-17-openjdk-devel qt5-qtbase-devel qt5-qtdeclarative-devel | |
| dnf clean all | |
| ln -sf "$(qmake-qt5 -query QT_INSTALL_HEADERS)" /usr/include/qt | |
| go install github.com/bazelbuild/bazelisk@latest | |
| ln -sf /root/go/bin/bazelisk /usr/local/bin/bazelisk | |
| ln -sf /root/go/bin/bazelisk /usr/local/bin/bazel | |
| - name: Set up Python ${{ matrix.python-version }} | |
| shell: bash | |
| run: | | |
| case "${{ matrix.python-version }}" in | |
| 3.11) PYBIN=/opt/python/cp311-cp311/bin ;; | |
| 3.12) PYBIN=/opt/python/cp312-cp312/bin ;; | |
| 3.13) PYBIN=/opt/python/cp313-cp313/bin ;; | |
| *) echo "unsupported python version: ${{ matrix.python-version }}" >&2; exit 1 ;; | |
| esac | |
| echo "$PYBIN" >> "$GITHUB_PATH" | |
| "$PYBIN/python3" --version | |
| - name: Build | |
| run: | | |
| make pypi-wheel | |
| pip3 install dist/*.whl --force-reinstall | |
| - name: Test | |
| run: | | |
| make release-test | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: wheel-${{ matrix.python-version }} | |
| path: wheelhouse/ | |
| if-no-files-found: error | |
| publish: | |
| if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }} | |
| runs-on: ubuntu-latest | |
| needs: [release] | |
| steps: | |
| - uses: actions/download-artifact@v8 | |
| with: | |
| pattern: wheel-* | |
| path: artifact | |
| merge-multiple: true | |
| - name: Move files so the next action can find them | |
| run: | | |
| mkdir dist && mv artifact/* dist/ | |
| ls dist/ | |
| - name: Publish distribution to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| password: ${{ secrets.PYPI_API_TOKEN }} |