Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions .github/workflows/build-wheels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Build Wheels (Windows)

on:
push:
branches: [ master, main ]
tags: [ 'v*' ]
pull_request:
branches: [ master, main ]
workflow_dispatch:

jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 90
strategy:
matrix:
os: [windows-latest]
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install CMake (Windows)
run: |
choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System'
refreshenv

- name: Install build dependencies
run: |
python -m pip install --upgrade pip
python -m pip install build wheel setuptools

- name: Clone dependencies
run: |
git clone --single-branch --depth 1 https://github.com/pybind/pybind11.git pybind11
git clone -b 20250127.1 --single-branch --depth 1 https://github.com/abseil/abseil-cpp.git open_spiel/abseil-cpp
git clone -b master https://github.com/nlohmann/json.git open_spiel/json
cd open_spiel/json && git checkout 9cca280a4d0ccf0c08f47a99aa71d1b0e52f8d03 && cd ../..
git clone -b master https://github.com/pybind/pybind11_json.git open_spiel/pybind11_json
cd open_spiel/pybind11_json && git checkout d0bf434be9d287d73a963ff28745542daf02c08f && cd ../..
git clone -b master https://github.com/pybind/pybind11_abseil.git open_spiel/pybind11_abseil
cd open_spiel/pybind11_abseil && git checkout 73992b5 && cd ../..
git clone -b develop --single-branch --depth 1 https://github.com/jblespiau/dds.git open_spiel/games/bridge/double_dummy_solver

- name: Build wheel
run: |
python -m build --wheel --outdir dist/
if (!(Test-Path dist/*.whl)) { Write-Error "No wheel file generated"; exit 1 }
Get-ChildItem dist/*.whl
shell: pwsh

- name: Test wheel installation
run: |
$wheel = Get-ChildItem dist/*.whl | Select-Object -First 1
python -m pip install $wheel.FullName
python -c "import pyspiel; game = pyspiel.load_game('tic_tac_toe'); print('OpenSpiel works! Game:', game.get_type().short_name)"
shell: pwsh

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}-py${{ matrix.python-version }}
path: dist/*.whl

upload_pypi:
needs: [build_wheels]
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: dist

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
packages_dir: dist/*/
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ To try OpenSpiel in Google Colaboratory, please refer to `open_spiel/colabs` sub
Please choose among the following options:

* [Installing OpenSpiel](docs/install.md)
* **[Windows Installation (pip install)](WINDOWS_INSTALL.md)**
* [Introduction to OpenSpiel](docs/intro.md)
* [API Overview and First Example](docs/concepts.md)
* [API Reference](docs/api_reference.md)
Expand Down
104 changes: 104 additions & 0 deletions WINDOWS_INSTALL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# OpenSpiel Windows Installation Guide

## Quick Installation (Recommended)

Simply install using pip:
```bash
pip install open-spiel
```

### Optional dependencies
For additional features like visualization and machine learning:
```bash
pip install open-spiel[full]
```

## Building from Source

If you need to build from source or contribute to the project:

### Prerequisites
- **Python 3.9+** (get from [python.org](https://python.org))
- **Git** (get from [git-scm.com](https://git-scm.com))
- **CMake 3.15+** (get from [cmake.org](https://cmake.org))
- **Visual Studio 2019 or later** with C++ development tools

### Build Steps
1. Clone the repository:
```bash
git clone https://github.com/deepmind/open_spiel.git
cd open_spiel
```

2. Build the wheel:
```bash
python -m pip wheel . --no-deps -w dist
```

3. Install the built wheel:
```bash
pip install dist/open_spiel-*.whl
```

## Verification

Test your installation:
```python
import pyspiel

# Create a simple game
game = pyspiel.load_game("tic_tac_toe")
state = game.new_initial_state()
print("OpenSpiel is working!")
```

## Troubleshooting

### Common Issues

**"CMake not found"**
- Install CMake from [cmake.org](https://cmake.org) and add it to your PATH

**"Git not found"**
- Install Git from [git-scm.com](https://git-scm.com) and add it to your PATH

**"MSVC compiler not found"**
- Install Visual Studio Community with C++ development tools
- Or install "Microsoft C++ Build Tools"

**"Import pyspiel failed"**
- Make sure you installed the package: `pip install open-spiel`
- Try reinstalling: `pip uninstall open-spiel && pip install open-spiel`

### Getting Help

- [Documentation](https://openspiel.readthedocs.io/)
- [Report Issues](https://github.com/deepmind/open_spiel/issues)
- [Discussions](https://github.com/deepmind/open_spiel/discussions)

## Advanced Usage

### Development Installation
```bash
git clone https://github.com/deepmind/open_spiel.git
cd open_spiel
pip install -e .
```

### Custom Build Options
```bash
# Set custom CMake flags
set CMAKE_ARGS=-DCMAKE_BUILD_TYPE=Debug
python -m pip install .
```

### Using with Conda
```bash
conda create -n openspiel python=3.9
conda activate openspiel
pip install open-spiel
```

---

**That's it!** You should now have OpenSpiel working on Windows with a simple `pip install` command.
10 changes: 10 additions & 0 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"""
OpenSpiel: A Framework for Reinforcement Learning in Games.
OpenSpiel is a collection of environments and algorithms for research in general
reinforcement learning and search/planning in games.
"""

import pyspiel

__all__ = ["pyspiel"]
47 changes: 26 additions & 21 deletions open_spiel/scripts/test_wheel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,30 +61,35 @@ if [[ "$MODE" = "full" ]]; then
fi

if [[ "$MODE" = "full" ]]; then
if [[ "$OS" = "Linux" ]]; then
file=`ls wheelhouse/open_spiel-*-cp312-cp312-manylinux*.whl`
${PYBIN} -m pip install $file
elif [[ "$OS" = "Darwin" && "$OS_PYTHON_VERSION" = "3.10" ]]; then
file=`ls wheelhouse/open_spiel-*-cp310-cp310-*.whl`
${PYBIN} -m pip install $file
elif [[ "$OS" = "Darwin" && "$OS_PYTHON_VERSION" = "3.11" ]]; then
file=`ls wheelhouse/open_spiel-*-cp311-cp311-*.whl`
${PYBIN} -m pip install $file
elif [[ "$OS" = "Darwin" && "$OS_PYTHON_VERSION" = "3.12" ]]; then
file=`ls wheelhouse/open_spiel-*-cp312-cp312-*.whl`
${PYBIN} -m pip install $file
elif [[ "$OS" = "Darwin" && "$OS_PYTHON_VERSION" = "3.13" && "$MODE" = "full" ]]; then
# file=`ls wheelhouse/open_spiel-*-cp312-cp312-*.whl`
# ${PYBIN} -m pip install $file
echo "Skipping full tests on MacOS Python 3.14 not yet available in brew / pypa."
# Special case: Skip full tests on macOS Python 3.13 (only cp314 wheel built)
if [[ "$OS" = "Darwin" && "$OS_PYTHON_VERSION" = "3.13" ]]; then
echo "Skipping full tests on macOS Python 3.13 (only Python 3.14 wheel available)"
exit 0
elif [[ "$OS" = "Darwin" && "$OS_PYTHON_VERSION" = "3.14" ]]; then
file=`ls wheelhouse/open_spiel-*-cp314-cp314-*.whl`
${PYBIN} -m pip install $file
fi

# Dynamically detect Python version and install matching wheel
PYTHON_VERSION=$(${PYBIN} --version 2>&1 | awk '{print $2}' | cut -d. -f1,2 | tr -d '.')
echo "Detected Python version: ${PYTHON_VERSION}, installing matching wheel for ${OS}"

if [[ "$OS" = "Linux" ]]; then
# Match both x86_64 and aarch64 wheels
WHEEL_FILE=$(ls wheelhouse/open_spiel-*-cp${PYTHON_VERSION}-cp${PYTHON_VERSION}-manylinux*.whl 2>/dev/null | head -1)
elif [[ "$OS" = "Darwin" ]]; then
WHEEL_FILE=$(ls wheelhouse/open_spiel-*-cp${PYTHON_VERSION}-cp${PYTHON_VERSION}-*.whl 2>/dev/null | head -1)
else
echo "Config not found for full tests"
exit -1
echo "ERROR: Unsupported OS: ${OS}"
exit 1
fi

if [[ -z "$WHEEL_FILE" ]]; then
echo "ERROR: No wheel found for Python ${PYTHON_VERSION} on ${OS}"
echo "Available wheels:"
ls wheelhouse/*.whl 2>/dev/null || echo "No wheels found in wheelhouse/"
exit 1
fi

echo "Installing wheel: $WHEEL_FILE"
${PYBIN} -m pip install "$WHEEL_FILE"
fi

export OPEN_SPIEL_BUILDING_WHEEL="ON"
Expand Down
65 changes: 65 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
[build-system]
requires = [
"setuptools>=45",
"wheel",
"cmake>=3.15",
"ninja; platform_system != 'Windows'",
]
build-backend = "setuptools.build_meta"

[project]
name = "open-spiel"
version = "1.6.10"
description = "A Framework for Reinforcement Learning in Games"
readme = "README.md"
requires-python = ">=3.10"
license = { text = "Apache-2.0" }
authors = [ {name = "The OpenSpiel authors", email = "open_spiel@google.com"} ]
keywords = ["reinforcement learning", "game theory", "artificial intelligence", "games"]
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: C++",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
"Topic :: Games/Entertainment",
"Topic :: Software Development :: Libraries :: Python Modules",
]

dependencies = [
"absl-py",
"attrs",
"numpy",
]

[project.optional-dependencies]
full = [
"matplotlib",
"nashpy",
"networkx",
"pillow",
"pygame",
"pygraphviz",
"scipy",
"tensorflow",
"torch",
]

[project.urls]
Homepage = "https://github.com/deepmind/open_spiel"
Repository = "https://github.com/deepmind/open_spiel.git"
Documentation = "https://openspiel.readthedocs.io/"
"Bug Tracker" = "https://github.com/deepmind/open_spiel/issues"

[tool.setuptools.packages.find]
where = ["."]
include = ["open_spiel*"]

[tool.setuptools.package-data]
"*" = ["*.so", "*.pyd", "*.dll"]
Loading