Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"fable": {
"version": "5.0.0-rc.2",
"version": "5.0.0",
"commands": [
"fable"
],
Expand Down
4 changes: 2 additions & 2 deletions Fable.Literate.Tests/Fable.Literate.Tests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<PackageReference Include="Fable.Pyxpecto" Version="2.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="YoloDev.Expecto.TestSdk" Version="0.14.3" />
<PackageReference Include="Fable.Core" Version="5.0.0-beta.4" />
<PackageReference Include="Fable.Python" Version="5.0.0-alpha.21.5" />
<PackageReference Include="Fable.Core" Version="5.0.0" />
<PackageReference Include="Fable.Python" Version="5.1.0" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions Fable.Literate/Fable.Literate.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Fable.Core" Version="5.0.0-beta.4" />
<PackageReference Include="Fable.Python" Version="5.0.0-alpha.21.5" />
<PackageReference Include="Fable.Core" Version="5.0.0" />
<PackageReference Include="Fable.Python" Version="5.1.0" />
</ItemGroup>

<ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion Fable.Literate/Python.fs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ let isMultilineDefinition (line: string) : bool =
/// Extracts the body of a multiline definition.
let extractMultilineBody (startIndex: int) (defIndex: int) (lines: string array) : string =
let shouldStop idx (line: string) =
idx > defIndex && (isTopLevelDefinition line || isDunderMethod line)
idx > defIndex
&& (isTopLevelDefinition line || isDunderMethod line)

// Start from decorator or definition line
lines[startIndex..]
Expand Down
13 changes: 6 additions & 7 deletions chapters/FableV5.fs
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,16 @@ pip install fable-library
uv add fable-library
```

For projects, pin your dependencies in `pyproject.toml`. For stable releases use
a minimum version constraint:
For projects, pin your dependencies in `pyproject.toml`:

```toml
dependencies = ["fable-library>=5.0.0"]
```

For pre-release versions, pin the exact version to avoid surprises:
To pin an exact version, use:

```toml
dependencies = ["fable-library==5.0.0rc2"]
dependencies = ["fable-library==5.0.0"]
```

This makes dependency management much simpler and follows Python conventions.
Expand All @@ -96,13 +95,13 @@ To use Fable v5, install the CLI:

```bash
# Install Fable 5 CLI
dotnet tool install fable --version 5.0.0-rc.2
dotnet tool install fable --version 5.0.0

# Add Fable.Core to your project
dotnet add package Fable.Core --version 5.0.0-rc.1
dotnet add package Fable.Core --version 5.0.0

# Install the Python runtime
uv add fable-library==5.0.0rc2
uv add fable-library==5.0.0
```

Then compile your F# to Python:
Expand Down
11 changes: 5 additions & 6 deletions chapters/GettingStarted.fs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ dotnet new console -lang F#

# Set up local tools and install Fable 5
dotnet new tool-manifest
dotnet tool install fable --version 5.0.0-rc.2
dotnet tool install fable --version 5.0.0

# Add Fable.Core package
dotnet add package Fable.Core --version 5.0.0-rc.1
dotnet add package Fable.Core --version 5.0.0
```

## Install Python Dependencies
Expand All @@ -53,17 +53,16 @@ Fable-generated Python code requires the `fable-library` runtime:

```bash
# Using uv (recommended)
uv add "fable-library==5.0.0rc2"
uv add "fable-library==5.0.0"

# Or with pip
pip install "fable-library==5.0.0rc2"
pip install "fable-library==5.0.0"
```

---

**Note:** Version pinning matters. The fable-library version must match your Fable
compiler version. Note that PyPI uses `5.0.0rc2` format instead of `5.0.0-rc.2` for
prerelease release candidate versions.
compiler version.

---

Expand Down
11 changes: 9 additions & 2 deletions chapters/Interop.fs
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,22 @@ For basic JSON operations, use Python's built-in `json` module:

open Fable.Python.Json

// Serialize F# data to JSON string
// Serialize F# data to a JSON string
let data = {|
name = "Alice"
age = 30
|}

let encoded = json.dumps data
// '{"name": "Alice", "age": 30}'

// Parse a JSON string back to a Python dict
let decoded = json.loads """{"city": "Oslo", "temp": -5}"""

(**
Anonymous records (`{| ... |}`) are perfect for JSON - they compile to
Python dictionaries. See the Compatibility chapter for details on how F#
Python dictionaries, so `json.dumps` and `json.loads` work directly without
any conversion layer. See the Compatibility chapter for details on how F#
types map to Python types.

## Calling Python Functions
Expand Down
4 changes: 2 additions & 2 deletions chapters/Testing.fs
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ project setup:
<ItemGroup>
<PackageReference Include="Expecto" Version="10.2.1" />
<PackageReference Include="Fable.Pyxpecto" Version="2.0.0" />
<PackageReference Include="Fable.Core" Version="5.0.0-rc.1" />
<PackageReference Include="Fable.Python" Version="5.0.0-rc.2" />
<PackageReference Include="Fable.Core" Version="5.0.0" />
<PackageReference Include="Fable.Python" Version="5.1.0" />
</ItemGroup>

<ItemGroup>
Expand Down
43 changes: 24 additions & 19 deletions docs/blogpost.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Introduction to Fable.Python

*Generated on 2026-03-08 17:54 UTC using Fable v5.0.0-rc.2*
*Generated on 2026-05-14 16:03 UTC using Fable v5.0.0*

> This post is part of the [F# Advent Calendar
2025](https://sergeytihon.com/2025/11/03/f-advent-calendar-in-english-2025/). Thank you, Sergey Tihon, for organizing
Expand Down Expand Up @@ -399,10 +399,10 @@ dotnet new console -lang F#

# Set up local tools and install Fable 5
dotnet new tool-manifest
dotnet tool install fable --version 5.0.0-rc.2
dotnet tool install fable --version 5.0.0

# Add Fable.Core package
dotnet add package Fable.Core --version 5.0.0-rc.1
dotnet add package Fable.Core --version 5.0.0
```

### Install Python Dependencies
Expand All @@ -411,17 +411,16 @@ Fable-generated Python code requires the `fable-library` runtime:

```bash
# Using uv (recommended)
uv add "fable-library==5.0.0rc2"
uv add "fable-library==5.0.0"

# Or with pip
pip install "fable-library==5.0.0rc2"
pip install "fable-library==5.0.0"
```

---

**Note:** Version pinning matters. The fable-library version must match your Fable
compiler version. Note that PyPI uses `5.0.0rc2` format instead of `5.0.0-rc.2` for
prerelease release candidate versions.
compiler version.

---

Expand Down Expand Up @@ -529,15 +528,22 @@ For basic JSON operations, use Python's built-in `json` module:
```fsharp
open Fable.Python.Json

// Serialize F# data to JSON string
// Serialize F# data to a JSON string
let data = {|
name = "Alice"
age = 30
|}

let encoded = json.dumps data
// '{"name": "Alice", "age": 30}'

// Parse a JSON string back to a Python dict
let decoded = json.loads """{"city": "Oslo", "temp": -5}"""
```

Anonymous records (`{| ... |}`) are perfect for JSON - they compile to
Python dictionaries. See the Compatibility chapter for details on how F#
Python dictionaries, so `json.dumps` and `json.loads` work directly without
any conversion layer. See the Compatibility chapter for details on how F#
types map to Python types.

### Calling Python Functions
Expand Down Expand Up @@ -2325,8 +2331,8 @@ project setup:
<ItemGroup>
<PackageReference Include="Expecto" Version="10.2.1" />
<PackageReference Include="Fable.Pyxpecto" Version="2.0.0" />
<PackageReference Include="Fable.Core" Version="5.0.0-rc.1" />
<PackageReference Include="Fable.Python" Version="5.0.0-rc.2" />
<PackageReference Include="Fable.Core" Version="5.0.0" />
<PackageReference Include="Fable.Python" Version="5.1.0" />
</ItemGroup>

<ItemGroup>
Expand Down Expand Up @@ -2458,17 +2464,16 @@ pip install fable-library
uv add fable-library
```

For projects, pin your dependencies in `pyproject.toml`. For stable releases use
a minimum version constraint:
For projects, pin your dependencies in `pyproject.toml`:

```toml
dependencies = ["fable-library>=5.0.0"]
```

For pre-release versions, pin the exact version to avoid surprises:
To pin an exact version, use:

```toml
dependencies = ["fable-library==5.0.0rc2"]
dependencies = ["fable-library==5.0.0"]
```

This makes dependency management much simpler and follows Python conventions.
Expand All @@ -2491,13 +2496,13 @@ To use Fable v5, install the CLI:

```bash
# Install Fable 5 CLI
dotnet tool install fable --version 5.0.0-rc.2
dotnet tool install fable --version 5.0.0

# Add Fable.Core to your project
dotnet add package Fable.Core --version 5.0.0-rc.1
dotnet add package Fable.Core --version 5.0.0

# Install the Python runtime
uv add fable-library==5.0.0rc2
uv add fable-library==5.0.0
```

Then compile your F# to Python:
Expand Down Expand Up @@ -3708,7 +3713,7 @@ For example, the extractSymbol function in F# generates this Python:
def extract_symbol(symbol: str, lines: Array[str]) -> str | None:
"""Extracts a single symbol definition from Python source lines."""

def mapping(def_index: int32, symbol: Any = symbol, lines: Any = lines) -> str:
def mapping(def_index: int32, lines: Any = lines) -> str:
start_index: int32 = find_decorator_start(lines, def_index)
if is_multiline_definition(lines[def_index]):
return extract_multiline_body(start_index, def_index, lines)
Expand Down
4 changes: 2 additions & 2 deletions fable-python.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Fable.Core" Version="5.0.0-beta.4" />
<PackageReference Include="Fable.Python" Version="5.0.0-alpha.21.5" />
<PackageReference Include="Fable.Core" Version="5.0.0" />
<PackageReference Include="Fable.Python" Version="5.1.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ authors = [
]
license = {text = "ISC"}
dependencies = [
"fable-library==5.0.0rc2",
"fable-library==5.0.0",
"pydantic>=2.12.5",
]

Expand Down
Loading
Loading