Skip to main content

stretchable

PyPI - Version Python Versions License GitHub issues GitHub Workflow Status (with event) Documentation Status Test results Test coverage

stretchable is a layout library for Python that enables context-agnostic layout operations using CSS Block, CSS Grid and Flexbox. Possible uses include UI layouts, page layouts for reports, complex plotting layouts, etc.

It implements Python bindings for Taffy, an implementation of CSS Block, Flexbox and CSS Grid layout algorithms written in Rust. It was originally based on Stretch (hence the name), but has since migrated to use Taffy. It is multi-platform and there are distributions available for Windows, Linux and macOS.

Getting Started

stretchable is a Python package hosted on PyPI. It can be installed using pip:

python -m pip install stretchable

Building a tree of nodes and calculating the layout is as simple as:

from stretchable import Edge, Node
from stretchable.style import AUTO, PCT

# Build node tree
root = Node(
    margin=20,
    size=(500, 300),
).add(
    Node(border=5, size=(50 * PCT, AUTO)),
    Node(key="child", padding=10 * PCT, size=50 * PCT),
)

# Compute layout
root.compute_layout()

# Get the second of the child nodes
child_node = root.find("/child")
content_box = child_node.get_box(Edge.CONTENT)
print(content_box)
# Box(x=300.0, y=50.0, width=150.0, height=50.0)

For more information and details, see the documentation.

Contributing

Contributions are welcomed. Please open an issue to clarify/plan implementation details prior to starting the work.

Building

Install Rust with rustup and use maturin develop for development and maturin build [--release] to build.

Documentation

To build documentation use make html (in docs/ folder) or, to use live reloading: sphinx-autobuild docs/source docs/build/html

NOTE: Sometimes, you may need to run make clean html (in docs/ folder) to ensure that all changes are included in the built html.

Testing

Install test dependencies and invoke pytest. Note that there are ~900 tests, the majority of which are run using Selenium with the Chrome WebDriver, and the complete test suite can take ~30 minutes to complete. Use pytest --lf to only run the last-failed tests.

To run basic tests and ensure compatibility with a specific Python version, use Docker and the provided Dockerfile: docker build . [--build-arg pyver=3.11] (defaults to lowest supported Python version, currently 3.8).

License

This work is released under the MIT license. A copy of the license is provided in the LICENSE file.

Release files for stretchable 1.1.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for stretchable 1.1.8
File
stretchable-1.1.8-cp38-abi3-win_arm64.whl CPython 3.8 abi3 Windows ARM64 Details
stretchable-1.1.8-cp38-abi3-win_amd64.whl CPython 3.8 abi3 Windows x86-64 Details
stretchable-1.1.8-cp38-abi3-win32.whl CPython 3.8 abi3 Windows x86-32 Details
stretchable-1.1.8-cp38-abi3-musllinux_1_2_x86_64.whl CPython 3.8 abi3 Linux musl 1.2+ x86-64 Details
stretchable-1.1.8-cp38-abi3-musllinux_1_2_aarch64.whl CPython 3.8 abi3 Linux musl 1.2+ ARM64 Details
stretchable-1.1.8-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.8 abi3 Linux glibc 2.17+ x86-64 Details
stretchable-1.1.8-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.8 abi3 Linux glibc 2.17+ ARM64 Details
stretchable-1.1.8-cp38-abi3-macosx_11_0_arm64.whl CPython 3.8 abi3 macOS 11.0+ ARM64 Details
stretchable-1.1.8-cp38-abi3-macosx_10_12_x86_64.whl CPython 3.8 abi3 macOS 10.12+ x86-64 Details

Total release size: 4.4 MB

Release files / stretchable-1.1.8-cp38-abi3-win_arm64.whl

Download URL stretchable-1.1.8-cp38-abi3-win_arm64.whl
Size 334.6 kB
Tags CPython 3.8 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
fec7556c160f73bd200af15570e6d219612499760172cb3485680e1286a7a316
BLAKE2b-256 checksum
How to use checksums
b86899d5ccda98a60954095f60a49287384d1105cc2ee1d0fec7692f72e549b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2025.

Transparency log

Release files / stretchable-1.1.8-cp38-abi3-win_amd64.whl

Download URL stretchable-1.1.8-cp38-abi3-win_amd64.whl
Size 356.8 kB
Tags CPython 3.8 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
42c10d864b3e8b2cb0ce16a64df6905318c6a78c6269041b1532c606bf6158c3
BLAKE2b-256 checksum
How to use checksums
9382f632174499bf13fec72e58872d1df56abedb8ab36b9a9c4d2940f73a5f0c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2025.

Transparency log

Release files / stretchable-1.1.8-cp38-abi3-win32.whl

Download URL stretchable-1.1.8-cp38-abi3-win32.whl
Size 347.4 kB
Tags CPython 3.8 Windows x86-32 abi3
SHA-256 checksum
How to use checksums
642c8025ec7ea12d37a66fb4cdd5619513efc6f1617cf1cafdb01d49c18a2dc3
BLAKE2b-256 checksum
How to use checksums
a999e58bb54055265fb01e387d414c33a62733821290cfa266509edb21d6446b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2025.

Transparency log

Release files / stretchable-1.1.8-cp38-abi3-musllinux_1_2_x86_64.whl

Download URL stretchable-1.1.8-cp38-abi3-musllinux_1_2_x86_64.whl
Size 697.1 kB
Tags CPython 3.8 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
b031ba4e400599c87ffcb9cd818f3939db6f5434aae49533481842939d507ba8
BLAKE2b-256 checksum
How to use checksums
13b6008bebdd0edbb320bc50a1cee93db1fb527b4381005ed3bed08c00d7bbe5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2025.

Transparency log

Release files / stretchable-1.1.8-cp38-abi3-musllinux_1_2_aarch64.whl

Download URL stretchable-1.1.8-cp38-abi3-musllinux_1_2_aarch64.whl
Size 686.4 kB
Tags CPython 3.8 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
7379be3622844bea7356fab3c83b0b46c10b3b8f5cabc7b2071134f7169c1226
BLAKE2b-256 checksum
How to use checksums
c5fe5201813989cf8c1c21692ac5afd1a2d36e11741325a46fd6bb1a768452f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2025.

Transparency log

Release files / stretchable-1.1.8-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL stretchable-1.1.8-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 530.1 kB
Tags CPython 3.8 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
1710c748f49c969fb067679847b371f49c1bc9923477a4f8d209029aee485809
BLAKE2b-256 checksum
How to use checksums
c8b6bf0bff56102d87f16cf953bf1bef64fd7682fa1533bea9fc42f2e863a9c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2025.

Transparency log

Release files / stretchable-1.1.8-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL stretchable-1.1.8-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 506.2 kB
Tags CPython 3.8 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
173b02e696763d1a1b922c9930d55740940c4a22290e11ae564a7574d175c54b
BLAKE2b-256 checksum
How to use checksums
0d0b7b3fbb028d6e82d624b72f9f3cae6a2fd753c994b405d479338a0f0da073
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2025.

Transparency log

Release files / stretchable-1.1.8-cp38-abi3-macosx_11_0_arm64.whl

Download URL stretchable-1.1.8-cp38-abi3-macosx_11_0_arm64.whl
Size 468.0 kB
Tags CPython 3.8 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
a9160a4013a1e37bd4c5dd4a6ea252cec2923cc91ba6bd68b20e7a1a8bfee8be
BLAKE2b-256 checksum
How to use checksums
6c4dadd8d6cbf3d64dc1ecc2e57d803063d618b623919391f07dd80b06710d40
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2025.

Transparency log

Release files / stretchable-1.1.8-cp38-abi3-macosx_10_12_x86_64.whl

Download URL stretchable-1.1.8-cp38-abi3-macosx_10_12_x86_64.whl
Size 486.7 kB
Tags CPython 3.8 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
e34e7988129b877bed1f9a247deed174ffed8066ab5b9a3178f18f1102836468
BLAKE2b-256 checksum
How to use checksums
5ea3e4c2b5420e4618550ea3153cd55921564c87aeb9206007c972c6512334dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2025.

Transparency log
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page