yoga-layout-python 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- yoga_layout_python-0.1.0/LICENSE +21 -0
- yoga_layout_python-0.1.0/PKG-INFO +158 -0
- yoga_layout_python-0.1.0/README.md +103 -0
- yoga_layout_python-0.1.0/pyproject.toml +77 -0
- yoga_layout_python-0.1.0/setup.cfg +4 -0
- yoga_layout_python-0.1.0/src/yoga/YGConfig.py +92 -0
- yoga_layout_python-0.1.0/src/yoga/YGEnums.py +404 -0
- yoga_layout_python-0.1.0/src/yoga/YGMacros.py +9 -0
- yoga_layout_python-0.1.0/src/yoga/YGNode.py +367 -0
- yoga_layout_python-0.1.0/src/yoga/YGNodeLayout.py +81 -0
- yoga_layout_python-0.1.0/src/yoga/YGNodeStyle.py +876 -0
- yoga_layout_python-0.1.0/src/yoga/YGPixelGrid.py +42 -0
- yoga_layout_python-0.1.0/src/yoga/YGValue.py +49 -0
- yoga_layout_python-0.1.0/src/yoga/__init__.py +16 -0
- yoga_layout_python-0.1.0/src/yoga/algorithm/AbsoluteLayout.py +417 -0
- yoga_layout_python-0.1.0/src/yoga/algorithm/Align.py +34 -0
- yoga_layout_python-0.1.0/src/yoga/algorithm/Baseline.py +54 -0
- yoga_layout_python-0.1.0/src/yoga/algorithm/BoundAxis.py +55 -0
- yoga_layout_python-0.1.0/src/yoga/algorithm/Cache.py +93 -0
- yoga_layout_python-0.1.0/src/yoga/algorithm/CalculateLayout.py +1651 -0
- yoga_layout_python-0.1.0/src/yoga/algorithm/FlexDirection.py +76 -0
- yoga_layout_python-0.1.0/src/yoga/algorithm/FlexLine.py +130 -0
- yoga_layout_python-0.1.0/src/yoga/algorithm/PixelGrid.py +56 -0
- yoga_layout_python-0.1.0/src/yoga/algorithm/SizingMode.py +39 -0
- yoga_layout_python-0.1.0/src/yoga/algorithm/TrailingPosition.py +34 -0
- yoga_layout_python-0.1.0/src/yoga/algorithm/__init__.py +18 -0
- yoga_layout_python-0.1.0/src/yoga/config/Config.py +137 -0
- yoga_layout_python-0.1.0/src/yoga/config/__init__.py +9 -0
- yoga_layout_python-0.1.0/src/yoga/debug/AssertFatal.py +24 -0
- yoga_layout_python-0.1.0/src/yoga/debug/Log.py +49 -0
- yoga_layout_python-0.1.0/src/yoga/debug/__init__.py +10 -0
- yoga_layout_python-0.1.0/src/yoga/event/__init__.py +9 -0
- yoga_layout_python-0.1.0/src/yoga/event/event.py +123 -0
- yoga_layout_python-0.1.0/src/yoga/node/CachedMeasurement.py +51 -0
- yoga_layout_python-0.1.0/src/yoga/node/LayoutResults.py +225 -0
- yoga_layout_python-0.1.0/src/yoga/node/LayoutableChildren.py +79 -0
- yoga_layout_python-0.1.0/src/yoga/node/Node.py +566 -0
- yoga_layout_python-0.1.0/src/yoga/node/__init__.py +11 -0
- yoga_layout_python-0.1.0/src/yoga/numeric/Comparison.py +46 -0
- yoga_layout_python-0.1.0/src/yoga/numeric/FloatMath.py +24 -0
- yoga_layout_python-0.1.0/src/yoga/numeric/FloatOptional.py +65 -0
- yoga_layout_python-0.1.0/src/yoga/numeric/__init__.py +10 -0
- yoga_layout_python-0.1.0/src/yoga/style/GridLine.py +44 -0
- yoga_layout_python-0.1.0/src/yoga/style/GridTrack.py +47 -0
- yoga_layout_python-0.1.0/src/yoga/style/SmallValueBuffer.py +133 -0
- yoga_layout_python-0.1.0/src/yoga/style/Style.py +763 -0
- yoga_layout_python-0.1.0/src/yoga/style/StyleLength.py +88 -0
- yoga_layout_python-0.1.0/src/yoga/style/StyleSizeLength.py +117 -0
- yoga_layout_python-0.1.0/src/yoga/style/StyleValueHandle.py +98 -0
- yoga_layout_python-0.1.0/src/yoga/style/StyleValuePool.py +191 -0
- yoga_layout_python-0.1.0/src/yoga/style/__init__.py +16 -0
- yoga_layout_python-0.1.0/src/yoga_layout_python.egg-info/PKG-INFO +158 -0
- yoga_layout_python-0.1.0/src/yoga_layout_python.egg-info/SOURCES.txt +99 -0
- yoga_layout_python-0.1.0/src/yoga_layout_python.egg-info/dependency_links.txt +1 -0
- yoga_layout_python-0.1.0/src/yoga_layout_python.egg-info/requires.txt +11 -0
- yoga_layout_python-0.1.0/src/yoga_layout_python.egg-info/top_level.txt +1 -0
- yoga_layout_python-0.1.0/tests/test_align_baseline_translation.py +489 -0
- yoga_layout_python-0.1.0/tests/test_align_items.py +195 -0
- yoga_layout_python-0.1.0/tests/test_align_self.py +196 -0
- yoga_layout_python-0.1.0/tests/test_aspect_ratio_translation.py +654 -0
- yoga_layout_python-0.1.0/tests/test_baseline_func_translation.py +74 -0
- yoga_layout_python-0.1.0/tests/test_clone_node_translation.py +98 -0
- yoga_layout_python-0.1.0/tests/test_computed_margin_translation.py +112 -0
- yoga_layout_python-0.1.0/tests/test_computed_padding_translation.py +112 -0
- yoga_layout_python-0.1.0/tests/test_config_translation.py +45 -0
- yoga_layout_python-0.1.0/tests/test_default_values_translation.py +213 -0
- yoga_layout_python-0.1.0/tests/test_dirtied_translation.py +114 -0
- yoga_layout_python-0.1.0/tests/test_dirty_marking_translation.py +242 -0
- yoga_layout_python-0.1.0/tests/test_edge_translation.py +147 -0
- yoga_layout_python-0.1.0/tests/test_events_translation.py +167 -0
- yoga_layout_python-0.1.0/tests/test_flex_direction.py +460 -0
- yoga_layout_python-0.1.0/tests/test_flex_gap_translation.py +68 -0
- yoga_layout_python-0.1.0/tests/test_flex_layout.py +340 -0
- yoga_layout_python-0.1.0/tests/test_float_optional_translation.py +201 -0
- yoga_layout_python-0.1.0/tests/test_generated_align_items_translation.py +183 -0
- yoga_layout_python-0.1.0/tests/test_had_overflow_translation.py +137 -0
- yoga_layout_python-0.1.0/tests/test_justify_content.py +669 -0
- yoga_layout_python-0.1.0/tests/test_layoutable_children_translation.py +117 -0
- yoga_layout_python-0.1.0/tests/test_margin.py +201 -0
- yoga_layout_python-0.1.0/tests/test_measure_cache_translation.py +153 -0
- yoga_layout_python-0.1.0/tests/test_measure_mode_translation.py +179 -0
- yoga_layout_python-0.1.0/tests/test_measure_translation.py +468 -0
- yoga_layout_python-0.1.0/tests/test_node_callback_translation.py +69 -0
- yoga_layout_python-0.1.0/tests/test_node_child_translation.py +78 -0
- yoga_layout_python-0.1.0/tests/test_ordinals_translation.py +22 -0
- yoga_layout_python-0.1.0/tests/test_padding.py +311 -0
- yoga_layout_python-0.1.0/tests/test_persistence_translation.py +265 -0
- yoga_layout_python-0.1.0/tests/test_persistent_node_cloning_translation.py +162 -0
- yoga_layout_python-0.1.0/tests/test_relayout_translation.py +116 -0
- yoga_layout_python-0.1.0/tests/test_rounding_function_translation.py +171 -0
- yoga_layout_python-0.1.0/tests/test_rounding_measure_func_translation.py +118 -0
- yoga_layout_python-0.1.0/tests/test_scale_change_translation.py +145 -0
- yoga_layout_python-0.1.0/tests/test_small_value_buffer_translation.py +115 -0
- yoga_layout_python-0.1.0/tests/test_smoke.py +104 -0
- yoga_layout_python-0.1.0/tests/test_style_translation.py +44 -0
- yoga_layout_python-0.1.0/tests/test_style_value_pool_translation.py +121 -0
- yoga_layout_python-0.1.0/tests/test_tree_mutation_translation.py +79 -0
- yoga_layout_python-0.1.0/tests/test_upstream_regressions.py +141 -0
- yoga_layout_python-0.1.0/tests/test_value_translation.py +24 -0
- yoga_layout_python-0.1.0/tests/test_yg_style_translation.py +80 -0
- yoga_layout_python-0.1.0/tests/test_zero_out_layout_translation.py +50 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: yoga-layout-python
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Pure Python port of Meta Yoga layout engine
|
|
5
|
+
Author: Meta Platforms, Inc. and affiliates.
|
|
6
|
+
Maintainer: Quantmew Contributors
|
|
7
|
+
License: MIT License
|
|
8
|
+
|
|
9
|
+
Copyright (c) Facebook, Inc. and its affiliates.
|
|
10
|
+
|
|
11
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
13
|
+
in the Software without restriction, including without limitation the rights
|
|
14
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
16
|
+
furnished to do so, subject to the following conditions:
|
|
17
|
+
|
|
18
|
+
The above copyright notice and this permission notice shall be included in all
|
|
19
|
+
copies or substantial portions of the Software.
|
|
20
|
+
|
|
21
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
|
+
SOFTWARE.
|
|
28
|
+
|
|
29
|
+
Project-URL: Homepage, https://github.com/quantmew/yoga-layout-python
|
|
30
|
+
Project-URL: Repository, https://github.com/quantmew/yoga-layout-python
|
|
31
|
+
Project-URL: Documentation, https://yogalayout.dev/
|
|
32
|
+
Classifier: Development Status :: 3 - Alpha
|
|
33
|
+
Classifier: Intended Audience :: Developers
|
|
34
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
35
|
+
Classifier: Programming Language :: Python :: 3
|
|
36
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
37
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
41
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
42
|
+
Requires-Python: >=3.9
|
|
43
|
+
Description-Content-Type: text/markdown
|
|
44
|
+
License-File: LICENSE
|
|
45
|
+
Provides-Extra: dev
|
|
46
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
47
|
+
Requires-Dist: pytest-cov>=4.0; extra == "dev"
|
|
48
|
+
Requires-Dist: black>=23.0; extra == "dev"
|
|
49
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
50
|
+
Requires-Dist: mypy>=1.0; extra == "dev"
|
|
51
|
+
Provides-Extra: test
|
|
52
|
+
Requires-Dist: pytest>=7.0; extra == "test"
|
|
53
|
+
Requires-Dist: pytest-cov>=4.0; extra == "test"
|
|
54
|
+
Dynamic: license-file
|
|
55
|
+
|
|
56
|
+
# yoga-layout-python
|
|
57
|
+
|
|
58
|
+
`yoga-layout-python` is a pure Python port of Meta's Yoga layout engine.
|
|
59
|
+
|
|
60
|
+
## Current Status
|
|
61
|
+
|
|
62
|
+
- Public enums, value/config primitives, and the core layout algorithm are implemented in Python.
|
|
63
|
+
- Internal module layout mirrors upstream `yoga/` so translation and parity work can stay file-for-file aligned.
|
|
64
|
+
- Upstream test translations pass, and a Python-vs-C++ differential parity harness is available under `tools/`.
|
|
65
|
+
|
|
66
|
+
## Installation
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
pip install -e .
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
For development:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
pip install -e ".[dev]"
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## API Shape
|
|
79
|
+
|
|
80
|
+
The Python package keeps Yoga's public naming style:
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
from yoga import *
|
|
84
|
+
|
|
85
|
+
config = YGConfigNew()
|
|
86
|
+
node = YGNodeNewWithConfig(config)
|
|
87
|
+
YGNodeStyleSetWidth(node, 100)
|
|
88
|
+
YGNodeStyleSetHeight(node, 50)
|
|
89
|
+
YGNodeCalculateLayout(node, YGUndefined, YGUndefined, YGDirectionLTR)
|
|
90
|
+
|
|
91
|
+
width = YGNodeLayoutGetWidth(node)
|
|
92
|
+
height = YGNodeLayoutGetHeight(node)
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Running Tests
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
# Run all tests
|
|
99
|
+
pytest
|
|
100
|
+
|
|
101
|
+
# Run with coverage
|
|
102
|
+
pytest --cov=yoga --cov-report=term-missing
|
|
103
|
+
|
|
104
|
+
# Run specific test file
|
|
105
|
+
pytest tests/test_smoke.py -v
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Differential Parity
|
|
109
|
+
|
|
110
|
+
The repository includes a differential parity runner that compares Python layout
|
|
111
|
+
results against the vendored upstream C++ Yoga engine on the same captured tree.
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
# Run the default parity suite
|
|
115
|
+
python tools/run_differential_ci.py
|
|
116
|
+
|
|
117
|
+
# Rebuild the C++ runner first
|
|
118
|
+
python tools/run_differential_ci.py --force-rebuild
|
|
119
|
+
|
|
120
|
+
# Increase the random batch size
|
|
121
|
+
python tools/run_differential_ci.py --random-count 1000 --seed 20260317
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
On failure, the script writes a repro capture to
|
|
125
|
+
`build/differential_failure_capture.json`.
|
|
126
|
+
|
|
127
|
+
The lower-level harness remains available if you want the raw output format:
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
python tools/differential_test.py
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Project Structure
|
|
134
|
+
|
|
135
|
+
```
|
|
136
|
+
src/yoga/
|
|
137
|
+
├── algorithm/ # Core layout algorithms (CalculateLayout, FlexLine, etc.)
|
|
138
|
+
├── config/ # Configuration handling
|
|
139
|
+
├── debug/ # Debug utilities (logging, assertions)
|
|
140
|
+
├── event/ # Event system
|
|
141
|
+
├── node/ # Node class and layout results
|
|
142
|
+
├── numeric/ # Numeric utilities (FloatOptional, Comparison)
|
|
143
|
+
├── style/ # Style system (Style, StyleLength, etc.)
|
|
144
|
+
└── *.py # Public API modules
|
|
145
|
+
|
|
146
|
+
tools/
|
|
147
|
+
├── differential_cpp_runner.cpp # C++ capture runner used for parity checks
|
|
148
|
+
├── differential_test.py # Python/C++ differential harness
|
|
149
|
+
└── run_differential_ci.py # Stable CLI entrypoint for parity checks
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## License
|
|
153
|
+
|
|
154
|
+
This project uses the same MIT license as upstream Yoga. See `LICENSE`.
|
|
155
|
+
|
|
156
|
+
## Contributing
|
|
157
|
+
|
|
158
|
+
Contributions are welcome! Please see the upstream [Yoga repository](https://github.com/facebook/yoga) for reference.
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# yoga-layout-python
|
|
2
|
+
|
|
3
|
+
`yoga-layout-python` is a pure Python port of Meta's Yoga layout engine.
|
|
4
|
+
|
|
5
|
+
## Current Status
|
|
6
|
+
|
|
7
|
+
- Public enums, value/config primitives, and the core layout algorithm are implemented in Python.
|
|
8
|
+
- Internal module layout mirrors upstream `yoga/` so translation and parity work can stay file-for-file aligned.
|
|
9
|
+
- Upstream test translations pass, and a Python-vs-C++ differential parity harness is available under `tools/`.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pip install -e .
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
For development:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pip install -e ".[dev]"
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## API Shape
|
|
24
|
+
|
|
25
|
+
The Python package keeps Yoga's public naming style:
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
from yoga import *
|
|
29
|
+
|
|
30
|
+
config = YGConfigNew()
|
|
31
|
+
node = YGNodeNewWithConfig(config)
|
|
32
|
+
YGNodeStyleSetWidth(node, 100)
|
|
33
|
+
YGNodeStyleSetHeight(node, 50)
|
|
34
|
+
YGNodeCalculateLayout(node, YGUndefined, YGUndefined, YGDirectionLTR)
|
|
35
|
+
|
|
36
|
+
width = YGNodeLayoutGetWidth(node)
|
|
37
|
+
height = YGNodeLayoutGetHeight(node)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Running Tests
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# Run all tests
|
|
44
|
+
pytest
|
|
45
|
+
|
|
46
|
+
# Run with coverage
|
|
47
|
+
pytest --cov=yoga --cov-report=term-missing
|
|
48
|
+
|
|
49
|
+
# Run specific test file
|
|
50
|
+
pytest tests/test_smoke.py -v
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Differential Parity
|
|
54
|
+
|
|
55
|
+
The repository includes a differential parity runner that compares Python layout
|
|
56
|
+
results against the vendored upstream C++ Yoga engine on the same captured tree.
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
# Run the default parity suite
|
|
60
|
+
python tools/run_differential_ci.py
|
|
61
|
+
|
|
62
|
+
# Rebuild the C++ runner first
|
|
63
|
+
python tools/run_differential_ci.py --force-rebuild
|
|
64
|
+
|
|
65
|
+
# Increase the random batch size
|
|
66
|
+
python tools/run_differential_ci.py --random-count 1000 --seed 20260317
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
On failure, the script writes a repro capture to
|
|
70
|
+
`build/differential_failure_capture.json`.
|
|
71
|
+
|
|
72
|
+
The lower-level harness remains available if you want the raw output format:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
python tools/differential_test.py
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Project Structure
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
src/yoga/
|
|
82
|
+
├── algorithm/ # Core layout algorithms (CalculateLayout, FlexLine, etc.)
|
|
83
|
+
├── config/ # Configuration handling
|
|
84
|
+
├── debug/ # Debug utilities (logging, assertions)
|
|
85
|
+
├── event/ # Event system
|
|
86
|
+
├── node/ # Node class and layout results
|
|
87
|
+
├── numeric/ # Numeric utilities (FloatOptional, Comparison)
|
|
88
|
+
├── style/ # Style system (Style, StyleLength, etc.)
|
|
89
|
+
└── *.py # Public API modules
|
|
90
|
+
|
|
91
|
+
tools/
|
|
92
|
+
├── differential_cpp_runner.cpp # C++ capture runner used for parity checks
|
|
93
|
+
├── differential_test.py # Python/C++ differential harness
|
|
94
|
+
└── run_differential_ci.py # Stable CLI entrypoint for parity checks
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## License
|
|
98
|
+
|
|
99
|
+
This project uses the same MIT license as upstream Yoga. See `LICENSE`.
|
|
100
|
+
|
|
101
|
+
## Contributing
|
|
102
|
+
|
|
103
|
+
Contributions are welcome! Please see the upstream [Yoga repository](https://github.com/facebook/yoga) for reference.
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=69", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "yoga-layout-python"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "Pure Python port of Meta Yoga layout engine"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = {file = "LICENSE"}
|
|
12
|
+
authors = [
|
|
13
|
+
{name = "Meta Platforms, Inc. and affiliates."}
|
|
14
|
+
]
|
|
15
|
+
maintainers = [
|
|
16
|
+
{name = "Quantmew Contributors"}
|
|
17
|
+
]
|
|
18
|
+
classifiers = [
|
|
19
|
+
"Development Status :: 3 - Alpha",
|
|
20
|
+
"Intended Audience :: Developers",
|
|
21
|
+
"License :: OSI Approved :: MIT License",
|
|
22
|
+
"Programming Language :: Python :: 3",
|
|
23
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
24
|
+
"Programming Language :: Python :: 3.9",
|
|
25
|
+
"Programming Language :: Python :: 3.10",
|
|
26
|
+
"Programming Language :: Python :: 3.11",
|
|
27
|
+
"Programming Language :: Python :: 3.12",
|
|
28
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
29
|
+
]
|
|
30
|
+
dependencies = []
|
|
31
|
+
|
|
32
|
+
[project.optional-dependencies]
|
|
33
|
+
dev = [
|
|
34
|
+
"pytest>=7.0",
|
|
35
|
+
"pytest-cov>=4.0",
|
|
36
|
+
"black>=23.0",
|
|
37
|
+
"ruff>=0.1.0",
|
|
38
|
+
"mypy>=1.0",
|
|
39
|
+
]
|
|
40
|
+
test = [
|
|
41
|
+
"pytest>=7.0",
|
|
42
|
+
"pytest-cov>=4.0",
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
[project.urls]
|
|
46
|
+
Homepage = "https://github.com/quantmew/yoga-layout-python"
|
|
47
|
+
Repository = "https://github.com/quantmew/yoga-layout-python"
|
|
48
|
+
Documentation = "https://yogalayout.dev/"
|
|
49
|
+
|
|
50
|
+
[tool.setuptools]
|
|
51
|
+
package-dir = {"" = "src"}
|
|
52
|
+
|
|
53
|
+
[tool.setuptools.dynamic]
|
|
54
|
+
version = {attr = "yoga.__version__"}
|
|
55
|
+
|
|
56
|
+
[tool.setuptools.packages.find]
|
|
57
|
+
where = ["src"]
|
|
58
|
+
|
|
59
|
+
[tool.pytest.ini_options]
|
|
60
|
+
testpaths = ["tests"]
|
|
61
|
+
python_files = "test_*.py"
|
|
62
|
+
python_functions = "test_*"
|
|
63
|
+
|
|
64
|
+
[tool.black]
|
|
65
|
+
line-length = 100
|
|
66
|
+
target-version = ["py39", "py310", "py311", "py312"]
|
|
67
|
+
|
|
68
|
+
[tool.ruff]
|
|
69
|
+
line-length = 100
|
|
70
|
+
target-version = "py39"
|
|
71
|
+
select = ["E", "F", "W", "I", "N", "UP", "B", "C4", "SIM"]
|
|
72
|
+
|
|
73
|
+
[tool.mypy]
|
|
74
|
+
python_version = "3.9"
|
|
75
|
+
warn_return_any = true
|
|
76
|
+
warn_unused_configs = true
|
|
77
|
+
disallow_untyped_defs = false
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
|
|
4
|
+
This source code is licensed under the MIT license found in the
|
|
5
|
+
LICENSE file in the root directory of this source tree.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from typing import Any
|
|
11
|
+
|
|
12
|
+
from .YGEnums import YGErrata, YGExperimentalFeature
|
|
13
|
+
from .config.Config import Config, _default_logger, getDefaultConfig, resolveRef
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
YGConfigRef = Config
|
|
17
|
+
YGConfigConstRef = Config
|
|
18
|
+
YGNodeRef = Any
|
|
19
|
+
YGNodeConstRef = Any
|
|
20
|
+
YGLogger = Any
|
|
21
|
+
YGCloneNodeFunc = Any
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def YGConfigNew() -> YGConfigRef:
|
|
25
|
+
return Config(logger_=_default_logger)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def YGConfigFree(config: YGConfigRef) -> None:
|
|
29
|
+
del config
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def YGConfigGetDefault() -> YGConfigConstRef:
|
|
33
|
+
return getDefaultConfig()
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def YGConfigSetUseWebDefaults(config: YGConfigRef, enabled: bool) -> None:
|
|
37
|
+
resolveRef(config).setUseWebDefaults(enabled)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def YGConfigGetUseWebDefaults(config: YGConfigConstRef) -> bool:
|
|
41
|
+
return resolveRef(config).useWebDefaults()
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def YGConfigSetPointScaleFactor(config: YGConfigRef, pixelsInPoint: float) -> None:
|
|
45
|
+
configRef = resolveRef(config)
|
|
46
|
+
if pixelsInPoint < 0.0:
|
|
47
|
+
raise ValueError("Scale factor should not be less than zero")
|
|
48
|
+
configRef.setPointScaleFactor(pixelsInPoint)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def YGConfigGetPointScaleFactor(config: YGConfigConstRef) -> float:
|
|
52
|
+
return resolveRef(config).getPointScaleFactor()
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def YGConfigSetErrata(config: YGConfigRef, errata: YGErrata) -> None:
|
|
56
|
+
resolveRef(config).setErrata(errata)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def YGConfigGetErrata(config: YGConfigConstRef) -> YGErrata:
|
|
60
|
+
return resolveRef(config).getErrata()
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def YGConfigSetLogger(config: YGConfigRef, logger: YGLogger) -> None:
|
|
64
|
+
configRef = resolveRef(config)
|
|
65
|
+
if logger is not None:
|
|
66
|
+
configRef.setLogger(logger)
|
|
67
|
+
else:
|
|
68
|
+
configRef.setLogger(_default_logger)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def YGConfigSetContext(config: YGConfigRef, context: object) -> None:
|
|
72
|
+
resolveRef(config).setContext(context)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def YGConfigGetContext(config: YGConfigConstRef) -> object:
|
|
76
|
+
return resolveRef(config).getContext()
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def YGConfigSetExperimentalFeatureEnabled(
|
|
80
|
+
config: YGConfigRef, feature: YGExperimentalFeature, enabled: bool
|
|
81
|
+
) -> None:
|
|
82
|
+
resolveRef(config).setExperimentalFeatureEnabled(feature, enabled)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def YGConfigIsExperimentalFeatureEnabled(
|
|
86
|
+
config: YGConfigConstRef, feature: YGExperimentalFeature
|
|
87
|
+
) -> bool:
|
|
88
|
+
return resolveRef(config).isExperimentalFeatureEnabled(feature)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def YGConfigSetCloneNodeFunc(config: YGConfigRef, callback: YGCloneNodeFunc) -> None:
|
|
92
|
+
resolveRef(config).setCloneNodeCallback(callback)
|