Giter VIP home page Giter VIP logo

ironpython-stubs's Introduction

IronPython Stubs

Stubs for common IronPython CLR assemblies. These stubs are intended to be used by the autocomplete engine of editors like Atom, Sublime, and Visual Studio Code.

Why IronPython Stubs?

If your are writing python code that targets IronPython, and using modules loaded through the Common Language Runtime (clr), your editor's autocomplete engine (which runs on regular python) will not be able to access those non-native modules. In other words, modules/or packages loaded through clr.AddReference() are not available on your autocomplete engine.

The workaround here is simple: Use IronPython to crawl through these libraries, and create 'stubs' or 'mock objects'. These 'stubs' can then be used by the CPython autocomplete engine. The stubs include doc strings as well as constructor/function/method signatures.

This repository contains the code to create these stubs, and also stores an a version of them that can be used by autocomplete-python.

sublime-large-demo


Documentation

Wiki

The wiki has step-by-step instructions for setting up your stubs for Atom, Sublime, Vim, Visual Studio Code.

For a list of supported Assemblies, see this list

If you haven't yet, read Note on Performance Large Namespaces such as Autodesk.Revit.DB can take a long time to be parsed and cached and might not show up right away.


Contribute - WIP

Generate Stubs - Examples

ipy -m ironstubs make RhinoCommon ipy -m ironstubs make --all ipy -m ironstubs make DSCoreNodes --folder="DSCore" --directory="C:/Program Files/Dynamo/Dynamo Core/1.3"

Process Stubs

WIP

Known Issues

  • Performance is not great for some of the larger classes. If you know how this can be improved please let me know.
  • Some of the function/constructor signatures are missing or incorrect. This is a problem with Generator3. Please send a PR or let me know if you have a fix.
  • Overloaded Methods do not show correct arguments

Credits

This project is a fork of the repository started by Gary Edwards on Gitlab. Thank you for your work Gary - and thank you Ehsan for pointing me to it.

It uses PyCharm's Generator3 to create the stubs.

ironpython-stubs's People

Contributors

aero9999 avatar chuongmep avatar garyedwards avatar gtalarico avatar htlcnn avatar tetov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ironpython-stubs's Issues

Grasshopper Component Stubs (ghpythonlib.components)

I've read [https://github.com//issues/6](Fix Grasshopper Stubs). However, this wasn't too helpful. Is there any way to add grasshopper component library, namely ghpythonlib.components, as a custom stub.
Could you give me an advice or direct me to documentation on how to achieve such task. Thank you in advance.

Issues getting Revit API functionality in IDEs

Hi,
I've followed all the installation and setup tutorials but I keep running into issues trying to use for example:
Autodesk.Revit.DB in any of the IDEs. I've tried VS Code, Sublime, but they simply don't work.

I have Python 2.7 and 3.8 installed.
But the autocomplete for these Revit libraries simply doesn't appear.

Any idea how to start understanding what is missing?

Wildcard imports are not picked up by autocomplete engine

Heyhey,
I'm a Dynamo-user, but coming from the Autodesk-Alias-side. I haven't ever opened Revit in my life, and I don't need it or the Revit-stubs, I just need to program generative geometry for Alias in Python. I have just spent the better part of a weekend trying to get autocomplete to work in Atom for the stubs released in this package. I'm having a hard time wrapping my head around all the different dependencies, maybe someone can help me here.
I am on Windows 10 on a fresh install of Atom 1.30, actually reinstalled just to get this working. I have followed the instructions installing python-autocomplete, got it working and going from there did the following.
I first tried using the ipy64.exe (and its path) in the python autocomplete settings, and pointed the "package"-setting to the cloned github respository:
C:\Users*user*\github\ironpython-stubs\release\stubs.min
My test, after restarting Atom, is always to start typing "Vector" in this file:
import clr clr.AddReference('ProtoGeometry') from Autodesk.DesignScript.Geometry import *

I don't get it to autocomplete "Vector", or "Point", or one of the class methods, nothing comes up.
I then tried leaving the python-version-field empty, pointing explicitely to my python 3.7 installed with anaconda (registered in the environment variable), and then installed a python 2.7 and pointed to that.
Regarding the stubs, like I wrote, I first tried pointing the "package"-field to the cloned repo, then copied them to the package-site folder in the IronPython directory leaving the field blank, then point explicitely to that folder, then making a C:\stubs\ folder and copying stuff in there.
For some reason, when I start typing "clr", I get autocomplete, but not for any of the classes or inputs I know from DesignScript in Dynamo.
Any ideas? Am I just impatient, and it needs to crawl all those stubs first? But how can I tell when it has finished? How could I debug this problem?
Maybe this is the wrong place for this, but I thought if we get this solved here someone else might be able to find it later.

Poor documentation

The documentation for both Atom and Sublime is extremely poor and is insufficient to successfully set up either editor.

Can you either update the documentation so time isn't wasted second-guessing what needs to be done (given up on both, and that was before I even got to the stubs!) or provide links to instructions online that provide adequate set-up instructions for these text editors.

Missing Revit Methods in VS Code and missing Revit Services and Transactions

Hi!

I have installed the iron stubs against Python v2.7.18 and have edited the settings.json file of Pylance to include extra paths as instructed with linting disabled.

I have intellisense for the basic imports and a few first level codes such as FilteredElementCollector, however, when I do FilteredElementCollector(doc). - after the "." nothing comes out. This is also the same for element.Category for example, nothing comes out as well.

I'd like to ask if this is the case or is there an error somewhere in my set up.

Appreciate the help. Thanks! :D
image

Intellisense does not work for "unknown" elements.

Hi,
thanks for providing this great tool :) I´m very pleased :)

But I run into a little problem with the intellisense. When pyCharm does not know which type my object has, it does not use intellisense and has no option to autocomplete.

I can put in if isinstance(element,type): and pyCharm shows intellisense now.
image

If I don´t, it doesn´t:
image

Is there any solution / workaround to this problem or am I doing something completely wrong? Casting an object with view = (DB.Elemt)view does not work.

Kind regards :)

Verify Blank Files Issue

Last rebuild left a few blank files.
Rebuild all and compare to first release to ensure nothing is being lost

Module cannot run

Hello all,
I'm trying use ironstubs module to create auto-completion for my .NET library. I'm using IronPython 3.4 and I placed the "ironstubs" folder in Lib directory (but the same behaviour happens if I use the code from outside that folder).
I added the path of my DLL in default_settings.py and launched ipy -m ironstubs myDLLname.
I get ImportError or ModuleNotFoundError exceptions on every import - the first I get is:
ModuleNotFoundError: No module named 'utils'

or

ImportError: No module named 'ConfigParser'

For utils error, I noticed that the error is gone when I correct the import statement in ironstubs.utils, and so on for all the import in the code. I started editing the code, but errors continues to appear, e.g.:
Unhandled exception: Traceback (most recent call last): File ".\runpy.py", line 182, in run_module File ".\ironstubs\generator3\pycharm_generator_utils\module_redeclarator.py", line 3, in <module> File ".\runpy.py", line 95, in _run_module_code File ".\runpy.py", line 85, in _run_code File ".\ironstubs\__main__.py", line 34, in <module> File "<string>", line 539, in _check_name_wrapper File "<string>", line 1614, in load_module File "<string>", line 596, in _load_module_shim File "<string>", line 1220, in load File "<string>", line 1200, in _load_unlocked File "<string>", line 1129, in _exec File "<string>", line 1471, in exec_module File "<string>", line 321, in _call_with_frames_removed File ".\ironstubs\make_stubs.py", line 40, in <module> File "<string>", line 539, in _check_name_wrapper File "<string>", line 1614, in load_module File "<string>", line 596, in _load_module_shim File "<string>", line 1220, in load File "<string>", line 1200, in _load_unlocked File "<string>", line 1129, in _exec File "<string>", line 1471, in exec_module File "<string>", line 321, in _call_with_frames_removed File ".\ironstubs\generator3\generator3.py", line 8, in <module> File "<string>", line 539, in _check_name_wrapper File "<string>", line 1614, in load_module File "<string>", line 596, in _load_module_shim File "<string>", line 1220, in load File "<string>", line 1200, in _load_unlocked File "<string>", line 1129, in _exec File "<string>", line 1471, in exec_module File "<string>", line 321, in _call_with_frames_removed ImportError: No module named 'util_methods'

What am I missing? Why do I have to fully qualify the path for every module imported?
Running with -X:FullFrames does not help.

thnks in advance

Pycharm Integration : Unavailable classes

Hi,

I installed the stubs. I am trying to use them in Pycharm. I am using Python 3.6.

When trying to import clr, it raises many errors. Mostly unavailable classes. For Example :
File "C:/Users/TOSHIBA/AppData/Roaming/JetBrains/PyCharmCE2020.1/scratches/scratch.py", line 1, in
import clr
File "C:\ProgramData\Anaconda3\envs\EnvPy36\lib\clr.py", line 702, in
class RuntimeReturnChecker(PythonTypeSlot):
NameError: name 'PythonTypeSlot' is not defined

What am I doing wrong ?

Maintainers Wanted

I am spread too thin with other OS projects, and since I don't use this project it's hard to justify spending time in this vs others.
I am happy to stay involved in the issues and help where I can,
but won't be able to continue development on this at this time.
Let me know if you are interested in helping maintaininig and developing it.
I would be happy to offer guidance.

Dependencies

Where can I find the required Package dependencies?

I'm specifically having the issue that "There is no module named docopt" -> installed docopt from pip -> "There is no module named utils.docopt" and I can't find where to get utils.docopt

IronPython stubs for Robot

Are you planning to do stubs on Robot?
if not, could you give some hints how to make stubs then? ...and would you be interested in adding it to you package if I then do the job?

Add instructions for Vim

I wrote up instructions for using ironpython-stubs with Vim on my blog and then reformatted it to fit with this repo's wiki. You can find the .md file here, GitHub doesn't allow pull requests to wikis..

If this change is accepted I'll make some gifs to add to the page.

Edit: I added some Asciinema videos to the linked gist.

How do I know which `*.dll` file I need

Hi, thanks for this project. I wanted to use it with Abaqus (a commercial finite element software), and read the issue #10, but I am not sure which *.dll file I should use. Is there a way to determine this? Because Abaqus has a lot of *.dll files. Furthermore, what are the strings in the ASSEMBLIES list in the default_settings.py file?

Error trying to generate new stubs

Hi,
I'm following the example here. to generate a set of stubs to use for autocomplete

I keep getting the following error.
image

Based on other suggestions for similar errors I've created a log.log file in the folder, but the error is persistent. I tried opening the individual files but I can't comprehend what is happening, and I did not wnat to mess up installations by editing the system files.

image

Any help is appreciated

Not work on a dll

Hello,

I am trying to process some RAM DataAccess dlls. I was only able to get it to work for "Interop.RAMDATAACCESSLib" I attempted others like RAMConcreteColumn and I got this error:

image

Would anyone have any suggests for me? Thank you

Create Github release(s) with only stubs.min

Creating a GitHub release with one of the assets being a zip file with only stubs.min could be useful for users who are not familiar with Git. We could add instructions to the wiki with a link to most recent stubs.min.

If this sounds like I good idea I'd happily set it up, I'll try to do a release with newly created stubs in that case.

How to make my own stubs?

Hello, could you please describe how to make my own stubs?
I'd like to add Autodesk Navisworks, AutoCAD, Civil3D and a couple of other dll's. I use VS Code.

ImportError: No module named 'utils.docopt'

I have ironpython installed, I can't get the ironpython-stub modules to work.

ipy -m ironstubs help
Unhandled exception:
Traceback (most recent call last):
  File "C:\Users\sfroehlich\.dotnet\tools\.store\ironpython.console\3.4.0\ironpython.console\3.4.0\tools\net6.0\any\lib\runpy.py", line 182, in run_module
  File ".\ironstubs\__main__.py", line 30, in <module>
  File "C:\Users\sfroehlich\.dotnet\tools\.store\ironpython.console\3.4.0\ironpython.console\3.4.0\tools\net6.0\any\lib\runpy.py", line 95, in _run_module_code
  File "C:\Users\sfroehlich\.dotnet\tools\.store\ironpython.console\3.4.0\ironpython.console\3.4.0\tools\net6.0\any\lib\runpy.py", line 85, in _run_code
ImportError: No module named 'utils.docopt'

From what I can tell, this line is trying to pull a module that is includes.

Add Instructions for VS Code

cdn-business.discourse.org/uploads/dynamobim/optimized/3X/2/5/2539fc0e2581100a21cd968bc8d944a7b3659057_1_690x303.gif

"python.autoComplete.extraPaths": [
    "C:\\Dropbox\\Shared\\dev\\repos\\ironpython-stubs\\stubs.min"
    ],
"python.pythonPath": "C:\\Python27\\python.exe",
"python.autoComplete.preloadModules": [
    "Autodesk.Revit.DB",
    "Autodesk.Revit.UI"
],

RevitNodes autocomplete pb

Hi, I can't get the aucompletion in those lines :

#if want to create a Curve in Dynamo
clr.AddReference("RevitNodes")                                  #Dynamo's nodes for Revit
import Revit                                                    #Loads in the Revit namespace in RevitNodes
clr.ImportExtensions(Revit.Elements)                            #Adds ToDSType (bool) extension method to Wrapped element
clr.ImportExtensions(Revit.GeometryConversion)                  #Adds ToProtoType, ToRevitType geometry conversion extension methods to objects

Why?

Fix Grasshopper Stubs

Parsing of Grasshopper.Kernel raises Unhandled Exception (UI alert, then crash):

System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
   at UnsafeNativeMethods.CRhinoDisplayConduit_SetCallback(Int32 which, ConduitCallback cb, ReportCallback reportcb)
   at Rhino.Display.DisplayPipeline.remove_CalculateBoundingBoxZoomExtents(EventHandler`1 value)
   at Grasshopper.Kernel.GH_Document.Finalize()

Possible solutions:

  • Edit process_one to handle error
  • Create module blacklist and skip misbehaving modules

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.