Skip to content

Commit b2b7637

Browse files
authored
Merge pull request #24 from fable-compiler/feature/asyncio
- Add initial asyncio support - Align with F# tasks - Fix builtins open
2 parents 4634758 + fc90795 commit b2b7637

File tree

14 files changed

+117
-36
lines changed

14 files changed

+117
-36
lines changed

.config/dotnet-tools.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
]
1616
},
1717
"fable-py": {
18-
"version": "4.0.0-alpha-012",
18+
"version": "4.0.0-alpha-013",
1919
"commands": [
2020
"fable-py"
2121
]

.github/workflows/build-and-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- name: Setup .NET Core
1616
uses: actions/setup-dotnet@v1
1717
with:
18-
dotnet-version: 5.0.400
18+
dotnet-version: 6.0.100
1919
- name: Setup dotnet tools
2020
run: dotnet tool restore
2121
- name: Install src dependencies

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: Setup .NET Core
1717
uses: actions/setup-dotnet@v1
1818
with:
19-
dotnet-version: 5.0.400
19+
dotnet-version: 6.0.100
2020

2121
- name: Setup tools
2222
run: dotnet tool restore

Build.fsproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<OutputType>Exe</OutputType>
4-
<TargetFramework>net5.0</TargetFramework>
4+
<TargetFramework>net6.0</TargetFramework>
55
</PropertyGroup>
66
<ItemGroup>
77
<Compile Include="Helpers.fs" />

examples/timeflies/TimeFlies.fsproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</ItemGroup>
1111
<ItemGroup>
1212
<PackageReference Include="Fable.Python" Version="0.16.0" />
13-
<PackageReference Include="Fable.Core.Experimental" Version="4.0.0-alpha-009" />
13+
<PackageReference Include="Fable.Core.Experimental" Version="4.0.0-alpha-010" />
1414
<PackageReference Include="FSharp.Control.AsyncRx" Version="1.6.0" />
1515
</ItemGroup>
1616
</Project>

paket.dependencies

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22

33
source https://api.nuget.org/v3/index.json
44
storage: none
5-
framework: net5.0, netstandard2.0, netstandard2.1
5+
framework: net6.0, netstandard2.0, netstandard2.1
66

77
nuget FSharp.Core ~> 4.7
8-
nuget Fable.Core.Experimental >= 4.0.0-alpha-002
8+
nuget Fable.Core.Experimental >= 4.0.0-alpha-013
99

1010
group Test
1111
source https://api.nuget.org/v3/index.json
1212
storage: none
13-
framework: net5.0
13+
framework: net6.0
1414

1515
nuget FSharp.Core
16-
nuget Fable.Core.Experimental >= 4.0.0-alpha-006
16+
nuget Fable.Core.Experimental >= 4.0.0-alpha-013
1717
nuget Microsoft.NET.Test.Sdk ~> 16
1818
nuget XUnit ~> 2
1919
nuget xunit.runner.visualstudio ~> 2
@@ -22,7 +22,7 @@ group Test
2222
group Build
2323
source https://api.nuget.org/v3/index.json
2424
storage: none
25-
framework: net5.0
25+
framework: net6.0
2626

2727
nuget Fake.Core.Target
2828
nuget Fake.IO.FileSystem

paket.lock

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
STORAGE: NONE
2-
RESTRICTION: || (== net5.0) (== netstandard2.0) (== netstandard2.1)
2+
RESTRICTION: || (== net6.0) (== netstandard2.0) (== netstandard2.1)
33
NUGET
44
remote: https://api.nuget.org/v3/index.json
5-
Fable.Core.Experimental (4.0.0-alpha-006)
6-
FSharp.Core (>= 4.7.2)
5+
Fable.Core.Experimental (4.0.0-alpha-013)
76
FSharp.Core (4.7.2)
87

98
GROUP Build
109
STORAGE: NONE
11-
RESTRICTION: == net5.0
10+
RESTRICTION: == net6.0
1211
NUGET
1312
remote: https://api.nuget.org/v3/index.json
1413
Fake.Core.CommandLineParsing (5.20.4)
@@ -53,23 +52,24 @@ NUGET
5352
FSharp.Control.Reactive (5.0.2)
5453
FSharp.Core (>= 4.7.2)
5554
System.Reactive (>= 5.0)
56-
FSharp.Core (6.0)
57-
System.Collections.Immutable (5.0)
55+
FSharp.Core (6.0.1)
56+
System.Collections.Immutable (6.0)
57+
System.Runtime.CompilerServices.Unsafe (>= 6.0)
5858
System.Reactive (5.0)
59+
System.Runtime.CompilerServices.Unsafe (6.0)
5960

6061
GROUP Test
6162
STORAGE: NONE
62-
RESTRICTION: == net5.0
63+
RESTRICTION: == net6.0
6364
NUGET
6465
remote: https://api.nuget.org/v3/index.json
65-
Fable.Core.Experimental (4.0.0-alpha-006)
66-
FSharp.Core (>= 4.7.2)
67-
FSharp.Core (6.0)
66+
Fable.Core.Experimental (4.0.0-alpha-013)
67+
FSharp.Core (6.0.1)
6868
Microsoft.CodeCoverage (17.0)
6969
Microsoft.NET.Test.Sdk (16.11)
7070
Microsoft.CodeCoverage (>= 16.11)
7171
Microsoft.TestPlatform.TestHost (>= 16.11)
72-
Microsoft.NETCore.Platforms (5.0.4)
72+
Microsoft.NETCore.Platforms (6.0)
7373
Microsoft.TestPlatform.ObjectModel (17.0)
7474
NuGet.Frameworks (>= 5.0)
7575
System.Reflection.Metadata (>= 1.6)
@@ -79,8 +79,12 @@ NUGET
7979
NETStandard.Library (2.0.3)
8080
Microsoft.NETCore.Platforms (>= 1.1)
8181
Newtonsoft.Json (13.0.1)
82-
NuGet.Frameworks (5.11)
83-
System.Reflection.Metadata (5.0)
82+
NuGet.Frameworks (6.0)
83+
System.Collections.Immutable (6.0)
84+
System.Runtime.CompilerServices.Unsafe (>= 6.0)
85+
System.Reflection.Metadata (6.0)
86+
System.Collections.Immutable (>= 6.0)
87+
System.Runtime.CompilerServices.Unsafe (6.0)
8488
xunit (2.4.1)
8589
xunit.analyzers (>= 0.10)
8690
xunit.assert (2.4.1)

src/Fable.Python.fsproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
<WarnOn>3390;$(WarnOn)</WarnOn>
1010
</PropertyGroup>
1111
<ItemGroup>
12+
<Compile Include="stdlib/asyncio/Futures.fs" />
13+
<Compile Include="stdlib/asyncio/Events.fs" />
14+
<Compile Include="stdlib/asyncio/Tasks.fs" />
1215
<Compile Include="stdlib/Ast.fs" />
1316
<Compile Include="stdlib/Base64.fs" />
1417
<Compile Include="stdlib/Builtins.fs" />
@@ -34,7 +37,7 @@
3437
</ItemGroup>
3538
<ItemGroup>
3639
<None Include="..\LICENSE" Pack="true" Visible="false" PackagePath="\" />
37-
<None Include="..\README.md" Pack="true" PackagePath="\"/>
40+
<None Include="..\README.md" Pack="true" PackagePath="\" />
3841
</ItemGroup>
3942
<Import Project="..\.paket\Paket.Restore.targets" />
4043
</Project>

src/stdlib/Builtins.fs

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

4+
open System
45
open System.Collections.Generic
56
open Fable.Core
67

@@ -11,6 +12,7 @@ type TextIOBase =
1112
abstract read : __size: int -> string
1213

1314
type TextIOWrapper =
15+
inherit IDisposable
1416
inherit TextIOBase
1517

1618
[<StringEnum>]
@@ -75,9 +77,11 @@ type OpenTextMode =
7577

7678
[<Erase>]
7779
type _OpenFile =
78-
| StrOrBytesPath of string
80+
| StringPath of string
7981
| FileDescriptor of int
8082

83+
type _Opener = Tuple<string, int> -> int
84+
8185
type IExports =
8286
/// Return the absolute value of the argument.
8387
abstract abs : int -> int
@@ -115,17 +119,8 @@ type IExports =
115119
/// Object to float
116120
abstract float : obj -> float
117121
abstract print : obj: obj -> unit
118-
abstract read : file: _OpenFile -> TextIOWrapper
119-
abstract read : file: _OpenFile * mode: OpenTextMode -> TextIOWrapper
120-
abstract read : file: _OpenFile * mode: OpenTextMode * buffering: int -> TextIOWrapper
121-
abstract read : file: _OpenFile * mode: OpenTextMode * buffering: int * encoding: string -> TextIOWrapper
122-
123-
abstract read :
124-
file: _OpenFile * mode: OpenTextMode * buffering: int * encoding: string * errors: string -> TextIOWrapper
125122

126-
abstract read :
127-
file: _OpenFile * mode: OpenTextMode * buffering: int * encoding: string * errors: string * newline: string ->
128-
TextIOWrapper
123+
[<NamedParams(fromIndex=1)>] abstract ``open`` : file: _OpenFile * ?mode: OpenTextMode * ?buffering: int * ?encoding: string * ?errors: string * ?newline: string * ?closefd: bool * ?opener: _Opener -> TextIOWrapper
129124

130125
[<ImportAll("builtins")>]
131126
let builtins: IExports = nativeOnly

src/stdlib/asyncio/Events.fs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace Fable.Python.AsyncIO
2+
3+
open Fable.Core
4+
5+
type [<AllowNullLiteral>] AbstractEventLoop =
6+
abstract member run_forever: unit -> unit
7+
abstract member create_future<'T> : unit -> Future<'T>

0 commit comments

Comments
 (0)