LabMaze
LabMaze is a standalone release of the maze generator used by DeepMind Lab, providing Python bindings to its C++ core. It can be configured to simplify paths and create rooms, and includes art assets to texture the environment. The primary purpose is to generate maze layouts for navigation tasks within other libraries. The current version is 1.0.6, released on December 5, 2022, indicating an infrequent release cadence focused on compatibility and bug fixes rather than new features.
Common errors
-
ERROR: Failed building wheel for labmaze
cause The most common cause is missing Bazel or an improperly configured build environment when `pip` attempts to compile the C++ source code, often because a pre-built wheel isn't available for your specific Python/OS/architecture. Errors like `command 'bazel' failed with exit status 1` or `error loading package '@com_google_absl//absl/strings'` are indicative.fixFirst, try `pip install labmaze`. If it fails, ensure you have Bazel installed and that your system's C++ build toolchain is set up correctly (e.g., XCode command line tools on macOS, Build Tools for Visual Studio on Windows, `build-essential` on Linux). For specific Python/Bazel versions, refer to the 'breaking' warnings. -
ERROR: Skipping '//labmaze/cc/python:_defaults': error loading package 'labmaze/cc/python': at .../bazel/build_defs.bzl:18:6: Unable to find package for @@[unknown repo 'bazel_skylib' requested from @@]//lib:collections.bzl: The repository '@@[unknown repo 'bazel_skylib' requested from @@]' could not be resolved: No repository visible as '@bazel_skylib' from main repository. Was the repository introduced in WORKSPACE?
cause This error points to an incompatibility with newer Bazel versions (e.g., Bazel 8 and above) which have changed the default behavior and deprecation of `WORKSPACE` files, impacting how `labmaze` resolves its Bazel dependencies. This is often observed with Python 3.13 and later.fixDowngrade your Python environment to a version known to be compatible with `labmaze`'s current build system (e.g., Python 3.10 or 3.11). Alternatively, if possible, check the `labmaze` GitHub repository for updates or workarounds for newer Bazel versions.
Warnings
- breaking Support for Python 2.7 was dropped around version 1.0.4. Ensure you are using Python 3.6 or newer.
- gotcha Installing `labmaze` from a source distribution (sdist) or on unsupported platforms/Python versions requires Bazel and a correctly configured C++ build toolchain. Pre-built wheels are only provided for specific Python versions (3.6-3.12) and OS/architectures (x64 Linux, macOS, Windows).
- breaking Newer versions of Python (e.g., 3.13) combined with Bazel 8+ might lead to build failures during installation. This is due to changes in Bazel's handling of `WORKSPACE` files, causing issues with resolving internal dependencies like `bazel_skylib`.
Install
-
pip install labmaze -
pip install bazel # Also install platform-specific build toolchain as per Bazel docs pip install labmaze --no-binary :all:
Imports
- RandomMaze
from labmaze import RandomMaze
- FixedMaze
from labmaze import FixedMaze
Quickstart
import labmaze
# Generate a random maze
maze = labmaze.RandomMaze(height=11, width=13, random_seed=42)
print("Random Maze Entity Layer:")
print(maze.entity_layer)
# Generate a maze from a fixed layout
# 'P' for player spawn, 'G' for goal
fixed_layout = """
###########
#P . . . G#
# . # . . #
# . # . . #
# . . . . #
###########
"""
fixed_maze = labmaze.FixedMaze(
text_maze=fixed_layout,
num_spawns=1, # Can be overridden if 'P' tokens are present
num_objects=1 # Can be overridden if 'G' tokens are present
)
print("\nFixed Maze Entity Layer:")
print(fixed_maze.entity_layer)