I work for a small sized company and we are planning to develop python plugins for opentap to test hardware equipments. My problem is that I cannot debug my python code in any IDE. The plugins I have created so far are functioning but I cannot debug the code itself.
First part of the problem is that I have not found a solution to successfully make Pycharm or VS recognize opentap imports inside the code (I mean lines like: “from opentap import *” are underlined). I’m aware that thisisn’t a major issue but would be very nice to be able to debug the code inside the IDE and not just trough log messages.
Second part of the problem is that I cannot use native debugging for visual studio. I open the project folder of my python plugin, under debug section I choose “attach to process“ and do everything as described here in the python integration guide: Debugging Your Code | OpenTAP Python Integration
Nothing happens if I try to set breakpoints and in the meanwhile run the test inside opentap gui (I use editor X).
Regarding the imports, make sure you open the root folder of your project in VS Code — not the folder containing only the Python modules.
The root folder should contain a subfolder with a similar name, but with the suffix “.Api” — this is the C# project. Before working with the Python code, you need to build the C# project first. To do this:
Open a terminal inside the Demo.Api folder.
Run the following command:
dotnet build
This build process generates type stubs for the C# OpenTAP types, which are required for IntelliSense (code completion) to work properly in your IDE.
For example, here is the content of the root directory of a demo project:
I have several problems but I think your guide has made me come closer to a solution.
First of all I was only trying to create a python project/package inside the Packages folder that is located in the original OpenTap Installation path described here in this section “Develop the plugin inside the Packages folder.“ : Creating an OpenTAP plugin | OpenTAP Python Integration
Reading your guide made me realize that I should try in this page the section “Developing the plugin in an insolated project folder.“ Because by creating a project this way dotnet build will generate all the necessary .net files like you have in your example. Unfortunately I had no luck by doing everything described in this section either. I have all the .dll files and folders as you have but after opening the project as you mentioned I still miss the imports.
So my first question would be that what could I have done wrong? The dotnet build was successfull but I also had a few warnings shown here.
C:\Users\Abel\Documents\opentap_project>dotnet buildRestore complete (3.4s)hvmc_test.Api succeeded with 9 warning(s) (7.3s) → bin\hvmc_test.Api.dllC:\Users\Abel\Documents\opentap_project\hvmc_test.Api\hvmc_test.Api.csproj : warning OpenTAP Install: Installer : Package ‘Python’ contains possibly relevant plugins for next package installations, but these will not be loaded.C:\Users\Abel\Documents\opentap_project\hvmc_test.Api\hvmc_test.Api.csproj(18): warning OpenTAP Reference: ../bin/Packages/Editor X/application/d3dcompiler_47.dll not recognized as a DotNet assembly. Reference not added.C:\Users\Abel\Documents\opentap_project\hvmc_test.Api\hvmc_test.Api.csproj(18): warning OpenTAP Reference: ../bin/Packages/Editor X/application/dxcompiler.dll not recognized as a DotNet assembly. Reference not added.C:\Users\Abel\Documents\opentap_project\hvmc_test.Api\hvmc_test.Api.csproj(18): warning OpenTAP Reference: ../bin/Packages/Editor X/application/dxil.dll not recognized as a DotNet assembly. Reference not added.C:\Users\Abel\Documents\opentap_project\hvmc_test.Api\hvmc_test.Api.csproj(18): warning OpenTAP Reference: ../bin/Packages/Editor X/application/ffmpeg.dll not recognized as a DotNet assembly. Reference not added.C:\Users\Abel\Documents\opentap_project\hvmc_test.Api\hvmc_test.Api.csproj(18): warning OpenTAP Reference: ../bin/Packages/Editor X/application/libEGL.dll not recognized as a DotNet assembly. Reference not added.C:\Users\Abel\Documents\opentap_project\hvmc_test.Api\hvmc_test.Api.csproj(18): warning OpenTAP Reference: ../bin/Packages/Editor X/application/libGLESv2.dll not recognized as a DotNet assembly. Reference not added.C:\Users\Abel\Documents\opentap_project\hvmc_test.Api\hvmc_test.Api.csproj(18): warning OpenTAP Reference: ../bin/Packages/Editor X/application/vk_swiftshader.dll not recognized as a DotNet assembly. Reference not added.C:\Users\Abel\Documents\opentap_project\hvmc_test.Api\hvmc_test.Api.csproj(18): warning OpenTAP Reference: ../bin/Packages/Editor X/application/vulkan-1.dll not recognized as a DotNet assembly. Reference not added.
Build succeeded with 9 warning(s) in 10.9s
My second question would be that creating a python project accordingly to the “Developing the plugin in an insolated project folder.“ section is the ultimate way to have a functioning developer environment for python, which detects all the imports and also is capable of debugging?
My last question would be that is it necessary to install Editor and opentap again inside the project whenever I create a new python project? Reading the section I already mentioned makes me wonder, for me it is not quite clear.
I use 64 bit opentap 9.28.0 with editor X right. Python version is 3.12 64 bit.
I would be very happy if you could share with me some additional information.
I’m also having the same issue. No typings folder is generated, even on 3.2.0-rc.3 of the Python plugin. This is one of the bigger pain points for our team with the Python integration for OpenTap, along with getting OpenTap to correctly locate the Python executable on the system and understanding the file/import structure for Python modules (we’ve been able to come up with a few workarounds, but it would be very helpful to have concrete documentation on these things).