Open atifaziz opened 1 month ago
I was initially thinking that this is something that could be tackled using codegen, basically taking a list of packages and then we generate the csproj, add the Python packages, and then run a dotnet pack
on them. But the idea falls down when I start thinking about the entrypoint for using a Python package.
Let's say we wanted a CSnakes.Numpy
package to be shipped on NuGet, well, what would the API surface area that someone would consume from the assembly look like? Are we trying to provide a bunch of generic methods that someone can do something with? Or do we need to provide some targeted APIs for someone to consume?
The more I think about it, the more I wonder if there's really anything that can be solved in CSnakes to support shipping via NuGet. The codegen from the source generator uses DI to get the Python environment, so there shouldn't be a conflict of configuring multiple Python environments (assuming you want to use the same Python version).
Maybe we could make CSnakes support loading the .py
file that the source generator built off via an embedded resource or dynamic file (so, embed the Python source in the assembly), but the reality is, you can ship arbitrary files inside a NuGet package anyway so it means you could distribute your Python and .NET assembly in a single package.
This is a feature request to allow developers to distribute libraries built using CSnakes via nuget.org for easy consumption by application and other libraries. Such libraries will be expected to leverage CSnakes and Python modules and packages internally and provide a friendlier .NET API.
Here is an initial summary of what's needed and/or desired for this:
IPythonEnvironment
that loads its modulesIPythonEnvironment
lies with the package consumer.import
statements.requirements.txt
.