You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/docs/python/build-and-run.md
+43-9Lines changed: 43 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,26 +9,60 @@ Fable targets Python 3.12 or higher.
9
9
10
10
Python 3.10 and 3.11 are deprecated.
11
11
12
+
## Installing fable-library
13
+
14
+
Fable Python requires the `fable-library` package to be installed from PyPI. This package contains the core runtime library that Fable-generated Python code depends on.
15
+
16
+
:::info
17
+
The fable-library is partially written in Rust for correctness. Installing from PyPI ensures you get pre-built binaries that are compatible with your Python version and system architecture.
18
+
:::
19
+
20
+
### Version Pinning
21
+
22
+
It is important to pin fable-library to a version compatible with your Fable compiler version. If you install an incompatible version, your generated code may not work correctly.
23
+
24
+
**For stable releases (e.g., Fable 5.x):**
25
+
26
+
```bash
27
+
pip install "fable-library>=5.0.0,<6.0.0"
28
+
```
29
+
30
+
or with Poetry (in `pyproject.toml`):
31
+
32
+
```toml
33
+
fable-library = ">=5.0.0,<6.0.0"
34
+
```
35
+
36
+
or with uv:
37
+
38
+
```bash
39
+
uv add "fable-library>=5.0.0,<6.0.0"
40
+
```
41
+
42
+
**For alpha/beta releases:** Pin to the exact version matching your Fable compiler. Note that PyPI uses a different naming convention (e.g., `5.0.0-alpha.17` becomes `5.0.0a17`):
43
+
44
+
```bash
45
+
pip install "fable-library==5.0.0a17"
46
+
```
47
+
12
48
## Running Python Code
13
49
14
-
When targeting python, you can use the output of Fable directly by running it with the python interpreter.
50
+
When targeting Python, you can use the output of Fable directly by running it with the Python interpreter.
15
51
16
52
For example:
17
53
18
54
```bash
19
55
python3 Program.py
20
56
```
21
57
22
-
## Publishing to PyPI
58
+
## Custom fable-library Path
23
59
24
-
If you want to publish a library to PyPI that uses Fable Python, you need to use `--fableLib` option to reference the pre-build Fable library:
25
-
26
-
:::info
27
-
This is because the Fable library is partially written in Rust and needs to be built for all architectures
28
-
:::
60
+
If you need to use a custom version of fable-library (e.g., for development or testing), you can use the `--fableLib` option:
This will make any reference to the Fable library point to a package in the Python search path (e.g., site-packages) instead of the normally bundled library. Your package will then need to declare `fable-library` as a dependency so users can install it from PyPI.
66
+
## Publishing to PyPI
67
+
68
+
When publishing a library to PyPI that uses Fable Python, your package should declare `fable-library` as a dependency with appropriate version constraints so users get a compatible version automatically.
0 commit comments