Skip to content

Commit eaf4f3b

Browse files
authored
doc: Update for PyPI fable-library is the default (#216)
1 parent 9d7acdf commit eaf4f3b

File tree

1 file changed

+43
-9
lines changed

1 file changed

+43
-9
lines changed

docs/docs/python/build-and-run.md

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,60 @@ Fable targets Python 3.12 or higher.
99

1010
Python 3.10 and 3.11 are deprecated.
1111

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+
1248
## Running Python Code
1349

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.
1551

1652
For example:
1753

1854
```bash
1955
python3 Program.py
2056
```
2157

22-
## Publishing to PyPI
58+
## Custom fable-library Path
2359

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:
2961

3062
```bash
31-
dotnet fable --lang python --fableLib fable-library
63+
dotnet fable --lang python --fableLib /path/to/custom/fable-library
3264
```
3365

34-
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

Comments
 (0)