phase-rs
Unofficial Python bindings for the phase.rs Magic: The Gathering rules engine.
from phase import Engine, Game, GameAction
Install from PyPI (prebuilt wheels; no Rust toolchain required):
pip install phase-python
The import name is phase. The distribution is phase-rs because phase is already taken on PyPI.
Card data
The engine needs a card-data.json oracle export. After installing the package, generate one with:
phase-gen -o card-data.json
Or generate card-data.json for one set only:
phase-gen --set SET -o card-data.json
If AtomicCards.json.gz is missing, phase-gen downloads it from MTGJSON. You can also pass an existing dump:
phase-gen -i AtomicCards.json.gz -o card-data.json
You can generate a card-data.json for single set with
phase-gen -i HOB.json -o card-data.json
A hosted snapshot is available at https://data.phase-rs.dev/card-data.json.
Quick start
from phase import Engine
engine = Engine.from_path("card-data.json")
game = engine.new_game(
player=["Forest"] * 60,
opponent=["Forest"] * 60,
seed=42,
first_player=0,
)
actions = game.actions()
result = game.apply(0, actions[0])
See API.md for the full Python API.
Develop from source
Requires Rust (see rust-toolchain.toml) and Python 3.10+.
uv venv && source .venv/bin/activate
uv pip install maturin
maturin develop --generate-stubs
License
MIT
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file phase_python-0.77.0.tar.gz.
File metadata
- Download URL: phase_python-0.77.0.tar.gz
- Upload date:
- Size: 65.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ecdcf85ec76f888bd3712bf3f7d8ae855f5738d3eb94e071a16c16eed0e8ea48
|
|
| MD5 |
ce827f6a1e7c0a17a1e5d8951c58df9b
|
|
| BLAKE2b-256 |
cf4bd1ed46df87ce8aa74b56614c998c3da860b7ad56050a5c58eb056c736771
|
File details
Details for the file phase_python-0.77.0-cp314-cp314-macosx_11_0_arm64.whl.
File metadata
- Download URL: phase_python-0.77.0-cp314-cp314-macosx_11_0_arm64.whl
- Upload date:
- Size: 23.8 MB
- Tags: CPython 3.14, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc66c9dab7a90ba0c43dae40f716ff9c0bc406e94e08ea4e37990cd7a34bd02d
|
|
| MD5 |
9a6232c684b040450762552a4ac5573d
|
|
| BLAKE2b-256 |
6a51b0f54de679b6e0e43b4eb4aceec5c2860ce7529c7a6a58ecc5e2dbf00a19
|
File details
Details for the file phase_python-0.77.0-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: phase_python-0.77.0-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 23.8 MB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f33b07293e46051b9c2d21b65a3fba3f23a00b3bb55e42a99b72b345ab70227
|
|
| MD5 |
36c7764d64b2546c6e30b50fcfc22a0e
|
|
| BLAKE2b-256 |
2f3998f008aba934b9f2a20f80c4aa26c951cbb2ebf5ca7b511e9b4f067a495c
|
File details
Details for the file phase_python-0.77.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: phase_python-0.77.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 25.0 MB
- Tags: CPython 3.11+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e7df5084aeeeda7040113154bce1dcd47022c982d3bd09abb040672ccf72bf9a
|
|
| MD5 |
34aaf2b5c659befe13a270ba1006fc27
|
|
| BLAKE2b-256 |
4a9fb8af450c8444711ec5f01cf51bde5f7a3de270d7aa34f35706f60c0dd500
|
File details
Details for the file phase_python-0.77.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: phase_python-0.77.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 24.0 MB
- Tags: CPython 3.11+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7c94fe723b7c591718b63211f6b5d81abea97118e626ff9ed2f58f6fc3bbcbde
|
|
| MD5 |
be8c748a0e3fac8e0f3f4eb39c5b3634
|
|
| BLAKE2b-256 |
476c19436891e129edf120e2c945061831cb6ec49227e1ed625b49fae35ee614
|
File details
Details for the file phase_python-0.77.0-cp311-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: phase_python-0.77.0-cp311-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 23.8 MB
- Tags: CPython 3.11+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e621c8ea80d14cac07ef6e0727244473a00daba80ba220259e276fd5baa4c27c
|
|
| MD5 |
410091a57cf0d3d4dbc69808807174c7
|
|
| BLAKE2b-256 |
dc4469e855883410b3ca7d97b64e06eafd84889e513c3bfac3cfb27bc46ab01c
|