MHDante / pythonnet-stub-generator

Creates Python Type Hints for Python.NET libraries
MIT License
20 stars 10 forks source link

Documentation improvements #7

Open mardukbp opened 3 months ago

mardukbp commented 3 months ago

First of all thank you for writing this awesome tool!

I installed it using .NET 8. When I executed GeneratePythonNetStubs I got the error (abridged):

You must install or update .NET to run this application.

Framework: 'Microsoft.NETCore.App', version '6.0.0' (x64)
.NET location: E:\dotnet-sdk-8-x64

Which means that it requires the .NET 6 x64 Runtime. I downloaded it, unpacked it in Downloads and then set the environment variable DOTNET_ROOT to the .NET 6 runtime. GeneratePythonNetStubs then did its magic :)

In order to use the typings in VS Code with the Python extension I added the following to settings.json:

"python.autoComplete.extraPaths": [
    "typings"
]

I think it would be great to provide these two pieces of information in the README so that people can benefit the most from your efforts.

mardukbp commented 3 months ago

Another tip. In order to automatically generate the typings after publishing the .NET Project with dotnet publish -c Release I added the following to the projects' .csproj file:

<PropertyGroup Condition="'$(Configuration)'=='Release'">
  <DebugSymbols>False</DebugSymbols>
  <DebugType>None</DebugType>
  <PublishDir>..\proj</PublishDir>
</PropertyGroup>

<Target Name="GenerateStubs" AfterTargets="Publish">
  <Exec Command="GeneratePythonNetStubs --dest-path=../../typings --target-dlls=../proj/CalcTest.dll"/>
</Target>
mardukbp commented 3 months ago

I found a simpler way to execute it with .NET 8:

GeneratePythonNetStubs --roll-forward LatestMajor --dest-path=../../typings --target-dlls=../proj/CalcTest.dll