Embed Python in .NET
Documentation CSnakes is a .NET Source Generator and Runtime that you can use to embed Python code and libraries into your C#.NET Solution at a performant, low-level without the need for REST, HTTP, or Microservices.
Check out the getting started guide or check out the demo solution to see more.
tuple, dict, list)CSnakes will generate a C#.NET class for any Python file in a project that is tagged as CSharp Analyzer Additional File (see Getting Started). All functions in that class with type annotations will be reflected to callable C# methods and an environment builder added to that module.
Given the following Python file called example.py
def hello_world(name: str, age: int) -> str:
return f"Hello {name}, you must be {age} years old!"CSnakes will generate a static .NET class called Example with the function:
public class Example {
public static string HelloWorld(string name, long age) {
...
}
}When called, HelloWorld() will invoke the Python function from example.py using Python's C-API and return native .NET types.
See the FAQ for more information.
No open issues yet, or sync has not completed.