rectangle-packer
Pack a set of rectangles into a bounding box with minimum area
What it is and what it does
rectangle-packer is a Python library that solves the 2D rectangle packing problem: given a collection of rectangles with fixed dimensions, it arranges them into a bounding box with minimal area and no overlaps. The package is implemented in C for performance and exposes a simple Python API that takes a list of (width, height) tuples and returns the (x, y) coordinates where each rectangle should be placed.
The library targets developers working on layout problems in graphics, game engines, texture atlasing, or any domain requiring efficient spatial arrangement of rectangular objects. It has no runtime dependencies and supports modern Python versions (3.9 through 3.14) across Linux, macOS, and Windows with precompiled wheels.
Use it for:
- Generate texture atlases for game engines by packing sprite sheets into minimal-area canvases.
- Optimize UI layout in graphics applications by arranging rectangular elements with minimal wasted space.
- Arrange rectangular bins or containers in warehouse or logistics planning simulations.
- Pack rectangular images or tiles into a single image file for efficient storage and rendering.
- Solve bin-packing problems in manufacturing or material-cutting scenarios.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Packs a set of rectangles with fixed orientations into a minimal-area bounding box with no overlaps, returning the (x, y) coordinates of each rectangle's lower-left corner.
Yes. The package is stable (Production/Stable status), actively maintained, has no known vulnerabilities, and solves a well-defined problem with a clean API. The medium install friction is offset by precompiled wheels for common platforms and Python versions. Install it if you need to pack rectangles efficiently.
Install
rectangle-packer on PyPI
pip
pip install rectangle-packeruv
uv add rectangle-packerpoetry
poetry add rectangle-packerInstalling rectangle-packer
Before you install
Medium install friction due to compiled wheels for multiple platforms and Python versions (3.9–3.14). Active maintenance with recent release (155 days ago) and no known vulnerabilities.
License in practice
MIT license is permissive; you can use, modify, and distribute this package with minimal restrictions.
Quickstart
python3 -m pip install rectangle-packer
Import the module and call pack() with a list of (width, height) tuples to get (x, y) coordinates for each rectangle's lower-left corner.
Requires Python 3.9 or later.
Verify before relying
- Whether the packing algorithm guarantees optimal solutions or uses a heuristic approach.
- Performance characteristics (time/space complexity) for large numbers of rectangles.
- Whether rectangles can be rotated or only placed in fixed orientations.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 155 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 207,686/month — #9,544 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: rectangle_packer-2.1.0-cp311-cp311-macosx_10_9_x86_64.whl; rectangle_packer-2.1.0-cp311-cp311-macosx_11_0_arm64.whl; rectangle_packer-2.1.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; rectangle_packer-2.1.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; rectangle_packer-2.1.0-cp311-cp311-musllinux_1_2_aarch64.whl; rectangle_packer-2.1.0-cp311-cp311-musllinux_1_2_x86_64.whl; rectangle_packer-2.1.0-cp311-cp311-win32.whl; rectangle_packer-2.1.0-cp311-cp311-win_amd64.whl; rectangle_packer-2.1.0-cp312-cp312-macosx_10_13_x86_64.whl; rectangle_packer-2.1.0-cp312-cp312-macosx_11_0_arm64.whl; rectangle_packer-2.1.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; rectangle_packer-2.1.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; rectangle_packer-2.1.0-cp312-cp312-musllinux_1_2_aarch64.whl; rectangle_packer-2.1.0-cp312-cp312-musllinux_1_2_x86_64.whl; rectangle_packer-2.1.0-cp312-cp312-win32.whl; rectangle_packer-2.1.0-cp312-cp312-win_amd64.whl; rectangle_packer-2.1.0-cp313-cp313-macosx_10_13_x86_64.whl; rectangle_packer-2.1.0-cp313-cp313-macosx_11_0_arm64.whl; rectangle_packer-2.1.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; rectangle_packer-2.1.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Keywords: pack, rectangle, packing, rectangles, enclosing, 2D
Tags
More Mathematics packages
NetworkX provides data structures and…
permissive · top 1,000 on PyPI
kiwisolverkiwisolver is a Python binding to a fast C++…
permissive · top 1,000 on PyPI
sympySymPy is a Python library for symbolic…
permissive · top 1,000 on PyPI
contourpyContourPy calculates contours of 2D…
permissive · top 1,000 on PyPI
torchPyTorch provides GPU-accelerated tensor…
permissive · top 1,000 on PyPI
onnxruntimeonnxruntime loads and executes Open Neural…
permissive · top 1,000 on PyPI
pybboxesConverts between bounding box formats (COCO,…
permissive · top 15,000 on PyPI
rectpackRectpack solves the 2D bin packing problem by…
permissive · top 15,000 on PyPI
squarifyComputes treemap layout rectangles from a list…
permissive · top 15,000 on PyPI
quadrilateral-fitterFits the smallest-area quadrilateral that…
permissive · top 15,000 on PyPI
PyRectPyRect provides a Rect class for representing…
permissive · top 5,000 on PyPI
py3dbpSolves the 3D bin packing problem by fitting…
permissive · top 5,000 on PyPI
binpackingDistributes weighted items into bins using…
permissive · top 15,000 on PyPI
prtpyImplements multiway number partitioning and bin…
permissive · top 15,000 on PyPI
qrdetDetects and segments QR codes in images using a…
permissive · top 15,000 on PyPI
PyWinBoxPyWinBox manages window positions, sizes, and…
permissive · top 15,000 on PyPI