File tree Expand file tree Collapse file tree 7 files changed +87
-10
lines changed Expand file tree Collapse file tree 7 files changed +87
-10
lines changed Original file line number Diff line number Diff line change 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.
Original file line number Diff line number Diff line change 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+ ```
Original file line number Diff line number Diff line change @@ -8,7 +8,6 @@ license = "MIT"
88
99[tool .poetry .dependencies ]
1010python = " ^3.8"
11- fable-library = " ^0.0.1"
1211Flask = " ^2.0.1"
1312
1413[tool .poetry .dev-dependencies ]
Original file line number Diff line number Diff line change @@ -16,6 +16,9 @@ These tools are needed by the Build script:
1616``` sh
1717pip install uflash
1818pip install microfs
19+
20+ dotnet tool restore
21+ dotnet restore
1922```
2023
2124## Build
@@ -30,4 +33,12 @@ dotnet run Build
3033dotnet 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
Original file line number Diff line number Diff line change 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+ ```
Original file line number Diff line number Diff line change 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 >
Original file line number Diff line number Diff line change 1+ /// Type bindings for Python builtins: https://docs.python.org/3/library/functions.html#built-in-funcs
12module Fable.Python.Builtins
23
34open 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" ) >]
130131let 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__" ) >]
133138let __name__ : string = nativeOnly
134139
You can’t perform that action at this time.
0 commit comments