GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - jkone27/Fable.Python: Python bindings for Fable

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

158 Commits
158 Commits

Folders and files

NameName
Last commit message
Last commit date
.config
.config
 
 
.github
.github
 
 
.paket
.paket
 
 
docs-src
docs-src
 
 
docs
docs
 
 
examples
examples
 
 
src
src
 
 
test
test
 
 
.editorconfig
.editorconfig
 
 
.fantomasignore
.fantomasignore
 
 
.gitignore
.gitignore
 
 
.nojekyll
.nojekyll
 
 
Build.fs
Build.fs
 
 
Build.fsproj
Build.fsproj
 
 
Fable.Python.sln
Fable.Python.sln
 
 
Helpers.fs
Helpers.fs
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
paket.dependencies
paket.dependencies
 
 
paket.lock
paket.lock
 
 
paket.references
paket.references
 
 
poetry.lock
poetry.lock
 
 
pyproject.toml
pyproject.toml
 
 

Repository files navigation

Fable Python

Build and Test Nuget

Fable is a compiler that translates F# source files to JavaScript and Python.

This Fable Python repository is a community driven project that contains the Python type bindings for Fable. The library will eventually contain Python (stdlib) bindings for Fable based on Python typeshed. It will also contain type binding for many other 3rd party libraries such as Flask, MicroBit and many more. Some bindings have already been added:

  • Python Standard Libray
  • Jupyter
  • Flask
  • CogniteSdk

Version

This library currently targets Python 3.10 or greater. Types bindings for other versions of Python should not be added to this library until we decide how to deal with Python version handling.

Installation

Prerequisite for compiling F# to Python using Fable:

> dotnet tool install --global fable --prerelease
> dotnet add package Fable.Core --prerelease

To use the Fable.Python library in your Fable project:

> dotnet add package Fable.Python

Usage

open Fable.Python.Json

let object = {| A=10; B=20 |}
let result = json.dumps object

To compile an F# Fable project to Python run e.g:

> fable --lang Python MyProject.fsproj

For more examples see the examples folder. It contains example code for using Fable Python with:

  • Flask. References Feliz.ViewEngine as a nuget package.
  • Timeflies, Cool demo using Tkinter and references FSharp.Control.AsyncRx as a nuget package.

Libraries that uses or works with Fable Python

  • Femto
  • AsyncRx
  • Fable.Aether
  • Fable.Giraffe, port of Giraffe to Fable.Python
  • Fable.Logging, logging for Fable.Python
  • Fable.Requests
  • Fable.Jupyter, Jupyter Notebook using Fable.Python
  • Fable.Pyexpecto, Fable-python equivalent for Fable.Mocha
  • Fable.SimpleJson.Python
  • Fable.Sedlex
  • Feliz.ViewEngine
  • FsToolkit.ErrorHandling
  • TypedCssClasses
  • Typed-BNF
  • Zanaptak.TypedCssClasses

Poetry

Fable.Python uses Poetry for package and dependency management. To handle dependencies when adding Fable Python compatible NuGet packages, you should use Femto.

Contributing

This project is community driven. If the type binding you are looking for is currently missing, then you need to add them to the relavant files (or add new ones). Open a PR to get them included.

The src/stdlib directory contains type bindings for modules in the Python 3 standard library. We also accept type bindings for 3rd party libraries as long as:

  • the package is publicly available on the Python Package Index;
  • the package supports any Python version supported by Fable Python; and
  • the package does not ship with its own stubs or type annotations

There's not much Python specific documentation yet, but the process of adding type bindings for Python is similar to JS:

  • https://fable.io/docs/communicate/js-from-fable.html
  • https://medium.com/@zaid.naom/f-interop-with-javascript-in-fable-the-complete-guide-ccc5b896a59f

Differences from JS

Note that import all is different from JS. E.g:

[<ImportAll("flask")>]
let flask: IExports = nativeOnly

This will generate import flask and not a wildcard import from flask import *. The latter version is discoraged anyways.

Auto-generation

Parts of this library could benefit from code-generation based on the type annotations in Python typeshed similar to ts2fable. Even so we should keep this library manually updated based on PRs to ensure the quality of the code.

Current plan:

  1. Add bindings for Python ast module (in progress)
  2. Use ast module to parse Python typeshed annotations
  3. Generate F# bindings

Road-map

  • Use a dedicated List.fs for Python. List.fs currently depends on Array.fs that is not an efficient list implementation for Python.

  • Compile Fable.Library as a published library (done)

  • Use poetry for Python references to Fable modules (done)

  • Update docs

About

Python bindings for Fable

fable.io/Fable.Python/

Resources

Readme
License
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.