Skip to main content

yoga-layout-python

yoga-layout-python is a pure Python port of Meta's Yoga layout engine.

Current Status

  • Public enums, value/config primitives, and the core layout algorithm are implemented in Python.
  • Internal module layout mirrors upstream yoga/ so translation and parity work can stay file-for-file aligned.
  • Upstream test translations pass, and a Python-vs-C++ differential parity harness is available under tools/.

Installation

pip install -e .

For development:

pip install -e ".[dev]"

API Shape

The Python package keeps Yoga's public naming style:

from yoga import *

config = YGConfigNew()
node = YGNodeNewWithConfig(config)
YGNodeStyleSetWidth(node, 100)
YGNodeStyleSetHeight(node, 50)
YGNodeCalculateLayout(node, YGUndefined, YGUndefined, YGDirectionLTR)

width = YGNodeLayoutGetWidth(node)
height = YGNodeLayoutGetHeight(node)

Running Tests

# Run all tests
pytest

# Run with coverage
pytest --cov=yoga --cov-report=term-missing

# Run specific test file
pytest tests/test_smoke.py -v

Differential Parity

The repository includes a differential parity runner that compares Python layout results against the vendored upstream C++ Yoga engine on the same captured tree.

# Run the default parity suite
python tools/run_differential_ci.py

# Rebuild the C++ runner first
python tools/run_differential_ci.py --force-rebuild

# Increase the random batch size
python tools/run_differential_ci.py --random-count 1000 --seed 20260317

On failure, the script writes a repro capture to build/differential_failure_capture.json.

The lower-level harness remains available if you want the raw output format:

python tools/differential_test.py

Project Structure

src/yoga/
├── algorithm/        # Core layout algorithms (CalculateLayout, FlexLine, etc.)
├── config/           # Configuration handling
├── debug/            # Debug utilities (logging, assertions)
├── event/            # Event system
├── node/             # Node class and layout results
├── numeric/          # Numeric utilities (FloatOptional, Comparison)
├── style/            # Style system (Style, StyleLength, etc.)
└── *.py              # Public API modules

tools/
├── differential_cpp_runner.cpp  # C++ capture runner used for parity checks
├── differential_test.py         # Python/C++ differential harness
└── run_differential_ci.py       # Stable CLI entrypoint for parity checks

License

This project uses the same MIT license as upstream Yoga. See LICENSE.

Contributing

Contributions are welcome! Please see the upstream Yoga repository for reference.

Metadata

Release files for yoga-layout-python 0.1.1

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

Source distribution (sdist)

Source distribution for yoga-layout-python 0.1.1
File Size Uploaded Provenance Actions
yoga_layout_python-0.1.1.tar.gz 75.5 kB Without provenance Details for yoga_layout_python-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for yoga-layout-python 0.1.1
File Interpreter ABI Platform Actions
yoga_layout_python-0.1.1-py3-none-any.whl Python 3 none any Details for yoga_layout_python-0.1.1-py3-none-any.whl

Total release size: 140.9 kB

Release files / yoga_layout_python-0.1.1.tar.gz

Download URL yoga_layout_python-0.1.1.tar.gz
Size 75.5 kB
Tags Source
SHA-256 checksum
How to use checksums
9b62b7fd9ebf406c5edb28ff78260942cb71999d92979939cb70db8517f32846
BLAKE2b-256 checksum
How to use checksums
e7bb110c845ec369303e1e4cb6f0a2b12c7718e8a549c8555b3c74871bd1573a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / yoga_layout_python-0.1.1-py3-none-any.whl

Download URL yoga_layout_python-0.1.1-py3-none-any.whl
Size 65.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
377fbb1c158d51c1722573ae2f52bba6fabfae1fbae788e413c21c2b36122298
BLAKE2b-256 checksum
How to use checksums
9821730caa04de6ed76b313d9251881ca266204a18e33534446eccf405d2c898
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Security for yoga-layout-python 0.1.1

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

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