Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

Python.NET 3.0 is awesome and has absolutely saved me from having to rewrite a bunch a code in order to use a audio fingerprinting library written in C# with a scraping library
written in Python because all the equivalent fingerprinting libraries for Python have awful DX. I can definitely see myself using this again as a lot of people are writing neat stuff in C# nowadays, so it would be awesome if starting a new project could be easy as:

# Install the templates
dotnet new -i pythonnet.Templates

# Start a new project
mkdir new-python-project
cd new-python-project
dotnet new console -lang Python

I imagine our main.py would look something like this in order to automatically load libraries installed with dotnet add and use .NET Core:

# Set .NET Core as our runtime
from clr_loader import get_coreclr
from pythonnet import set_runtime

rt = get_coreclr("/home/pythonnet/new-python-project/bin/Debug/net6.0/new-python-project.runtimeconfig.json")
set_runtime(rt)

# Load dynamic libraries 
import sys
import clr
DLL_PATH = "/home/pythonnet/new-python-project/bin/Debug/net6.0/"
sys.path.append(DLL_PATH)

from System import Console

Console.WriteLine("Hello World")

Here are the associated docs: https://docs.microsoft.com/en-us/dotnet/core/tools/custom-templates

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
💡
Ideas
Labels
None yet
1 participant
Morty Proxy This is a proxified and sanitized view of the page, visit original site.