Skip to content

Commit 6573c2f

Browse files
committed
Add readme for each example
1 parent b3edb6c commit 6573c2f

File tree

7 files changed

+87
-10
lines changed

7 files changed

+87
-10
lines changed

examples/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Fable Python Examples
2+
3+
See the `README.md` in each directory on how to run them. Some examples
4+
use project references against the top-level `Fable.Python.fsproj` while
5+
others reference the
6+
[`Fable.Python`](https://www.nuget.org/packages/Fable.Python/) NuGet
7+
instead.
8+
9+
- BBC micro:bit, use Fable Python with MicroPython and the BBC micro:bit
10+
11+
- Flask, use Fable Python to make web applications
12+
13+
- Timeflies, use Fable Python with Tkinter and AsyncRx
14+
15+
NOTE: If you make demos or examples with Fable Python then please
16+
consider providing a PR so we can add it here.

examples/flask/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Fable Python on Flask
2+
3+
## Install Dependencies
4+
5+
```sh
6+
> dotnet tool restore
7+
> dotnet restore
8+
9+
> pip install flask
10+
> rehash # so you can run flask below
11+
```
12+
13+
## Build
14+
15+
```
16+
> dotnet fable-py
17+
```
18+
19+
## Run
20+
21+
```sh
22+
> flask run
23+
```

examples/flask/pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ license = "MIT"
88

99
[tool.poetry.dependencies]
1010
python = "^3.8"
11-
fable-library = "^0.0.1"
1211
Flask = "^2.0.1"
1312

1413
[tool.poetry.dev-dependencies]

examples/microbit/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ These tools are needed by the Build script:
1616
```sh
1717
pip install uflash
1818
pip install microfs
19+
20+
dotnet tool restore
21+
dotnet restore
1922
```
2023

2124
## Build
@@ -30,4 +33,12 @@ dotnet run Build
3033
dotnet run Flash
3134
```
3235

36+
## Copy Fable Library
37+
38+
Flashing will not copy the Fable Library (just `util.py` for now), so it
39+
needs to be transferred separately:
40+
41+
```sh
42+
dotnet run FableLibrary
43+
```
3344

examples/timeflies/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Time Flies Like An Arrow
2+
3+
Demo using Tkinter with AsyncRx. Fully self-contained and only
4+
references NuGet packages.
5+
6+
## Install Dependencies
7+
8+
```sh
9+
> pip install tkinter
10+
11+
> dotnet tool restore
12+
> dotnet restore
13+
```
14+
15+
## Build
16+
17+
```sh
18+
> dotnet fable-py
19+
```
20+
21+
22+
## Run
23+
24+
```sh
25+
> python program.py
26+
```

examples/timeflies/TimeFlies.fsproj

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,8 @@
99
<Compile Include="Program.fs" />
1010
</ItemGroup>
1111
<ItemGroup>
12-
<PackageReference Include="Fable.Python" Version="0.5.0" />
12+
<PackageReference Include="Fable.Python" Version="0.9.0" />
13+
<PackageReference Include="Fable.Core.Experimental" Version="4.0.0-alpha-003" />
1314
<PackageReference Include="FSharp.Control.AsyncRx" Version="1.6.0" />
1415
</ItemGroup>
15-
<ItemGroup>
16-
<ProjectReference Include="../GitHub/Fable/src/Fable.Core/Fable.Core.fsproj" />
17-
</ItemGroup>
18-
<Import Project="..\..\.paket\Paket.Restore.targets" />
19-
</Project>
16+
</Project>

src/stdlib/Builtins.fs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/// Type bindings for Python builtins: https://docs.python.org/3/library/functions.html#built-in-funcs
12
module Fable.Python.Builtins
23

34
open System.Collections.Generic
@@ -107,11 +108,11 @@ type IExports =
107108
abstract map : ('T1 * 'T2 * 'T3 -> 'T4) * IEnumerable<'T1> * IEnumerable<'T2> * IEnumerable<'T3> -> IEnumerable<'T4>
108109
/// Return the Unicode code point for a one-character string.
109110
abstract ord : char -> int
110-
// Object to string
111+
/// Object to string
111112
abstract str : obj -> string
112-
// Object to int
113+
/// Object to int
113114
abstract int : obj -> int
114-
// Object to float
115+
/// Object to float
115116
abstract float : obj -> float
116117
abstract print : obj: obj -> unit
117118
abstract read : file: _OpenFile -> TextIOWrapper
@@ -129,6 +130,10 @@ type IExports =
129130
[<ImportAll("builtins")>]
130131
let builtins: IExports = nativeOnly
131132

133+
// NOTE: Below we can add builtins that don't require overloads, and do not
134+
// conflict with common F# or .NET functions. If they do we keep them in
135+
// `IExports` above.
136+
132137
[<Emit("__name__")>]
133138
let __name__: string = nativeOnly
134139

0 commit comments

Comments
 (0)