Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate code automatically via tools provided by JetBrains? #5

Closed
gzxu opened this issue Dec 29, 2018 · 8 comments
Closed

Generate code automatically via tools provided by JetBrains? #5

gzxu opened this issue Dec 29, 2018 · 8 comments

Comments

@gzxu
Copy link

gzxu commented Dec 29, 2018

git clone --depth 1 https://github.com/JetBrains/intellij-community.git /tmp/idea
mkdir /tmp/out
for typelib in Atk GLib GModule GObject Gdk GdkPixbuf Gio Gtk Pango; do
    python3 /tmp/idea/python/helpers/generator3.py -d /tmp/out -x gi.repository.$typelib $(python3 -c "from gi.repository import $typelib; print($typelib.__path__[-1])")
done

And stubs can be found under /tmp/out. Currently this repository seems to be much incomplete?

@lazka
Copy link
Member

lazka commented Dec 29, 2018

Yeah, it's work in progress: pygobject/pgi-docgen#176

@AdamVerner
Copy link

what about Fakegir?

@ju1ius
Copy link

ju1ius commented Oct 26, 2019

@AdamVerner Fakegir generates stubs from gir xml files, while the JetBrains tool generates them by doing a runtime introspection. Last time I checked, the stubs generated by the JetBrains tool were way more exhaustive and accurate.

@ttys3
Copy link

ttys3 commented Jun 5, 2020

git clone --depth 1 https://github.com/JetBrains/intellij-community.git /tmp/idea
mkdir /tmp/out
for typelib in Atk GLib GModule GObject Gdk GdkPixbuf Gio Gtk Pango; do
    python3 /tmp/idea/python/helpers/generator3.py -d /tmp/out -x gi.repository.$typelib $(python3 -c "from gi.repository import $typelib; print($typelib.__path__[-1])")
done

And stubs can be found under /tmp/out. Currently this repository seems to be much incomplete?

year 2020 now, still find you tips works fine with litlte mod:

if you have pycharm installed, no need to clone the intellij-community repo.

just replace the command below

python3 /tmp/idea/python/helpers/generator3/__main__.py

with

PYTHONPATH=$HOME/Apps/pycharm-community/plugins/python-ce/helpers python3 -m generator3

$HOME/Apps/pycharm-community is the pycharm installation path of mine, please use your own path.

git clone --depth 1 https://github.com/JetBrains/intellij-community.git /tmp/idea
mkdir /tmp/out
for typelib in Atk GLib GModule GObject Gdk GdkPixbuf Gio Gtk Pango; do
    python3  /tmp/idea/python/helpers/generator3/__main__.py -d /tmp/out -p gi.repository.$typelib $(python3 -c "import gi; gi.require_versions({'Atk': '1.0', 'GModule': '2.0', 'Gdk': '3.0', 'GdkPixbuf': '2.0', 'Gtk': '3.0', 'Pango': '1.0'}); from gi.repository import $typelib; print($typelib.__path__[-1])")
done

make pyCharm can use it

mv /tmp/out/gi ~/.local/lib/python3.8/site-packages/gi-stubs

but there's little troubleshoot:
we need let generator3 run gi.require_versions({'Atk': '1.0', 'GModule': '2.0', 'Gdk': '3.0', 'GdkPixbuf': '2.0', 'Gtk': '3.0', 'Pango': '1.0'}) before using the $typelib

otherwise there will be a warning:
PyGIWarning: Gtk was imported without specifying a version first. Use gi.require_version('Gtk', '3.0') before import to ensure that the right version gets loaded.

anyway, the generated stubs works quite well, in my word, it is better than PyGObject-stubs.
since PyGObject-stubs provides no param info.

@ttys3
Copy link

ttys3 commented Jun 5, 2020

update:

I’ve make a new repo and pushed the auto generated stubs:

https://github.com/ttys3/pygobject-stubs

@dsvensson
Copy link

@ttys3 are these supposed to work with pyright?

@danyeaw
Copy link

danyeaw commented Oct 13, 2020

@lazka What do you think about merging @ttys3's fork so that we can have a new PyPI release?

@lovetox
Copy link
Collaborator

lovetox commented Jul 16, 2022

I will close this, stubs like this can be generated with generate script in this repo for modules which users need. Apart from that the real signatures have to be added manually.

@lovetox lovetox closed this as completed Jul 16, 2022
CharlieQLe pushed a commit to CharlieQLe/pygobject-stubs that referenced this issue Dec 19, 2022
# This is the 1st commit message:

other: Reformat codebase with black

# This is the commit message #2:

Add Adw

# This is the commit message #3:

Add types for functions

# This is the commit message pygobject#4:

Add types for ActionRow

# This is the commit message pygobject#5:

Add types for Adw.Animation

# This is the commit message pygobject#6:

Add types for Adw.Application

# This is the commit message pygobject#7:

Add types for Adw.ApplicationWindow

# This is the commit message pygobject#8:

Update Gdk to 4.0

# This is the commit message pygobject#9:

Move Gdk into correct location

# This is the commit message pygobject#10:

Add types for Adw.Avatar

# This is the commit message pygobject#11:

Add types for Adw

# This is the commit message pygobject#12:

Removed Typing import

# This is the commit message pygobject#13:

Add types for Adw
CharlieQLe added a commit to CharlieQLe/pygobject-stubs that referenced this issue Dec 19, 2022
# This is the 1st commit message:

other: Reformat codebase with black

# This is the commit message #2:

Add Adw

# This is the commit message #3:

Add types for functions

# This is the commit message pygobject#4:

Add types for ActionRow

# This is the commit message pygobject#5:

Add types for Adw.Animation

# This is the commit message pygobject#6:

Add types for Adw.Application

# This is the commit message pygobject#7:

Add types for Adw.ApplicationWindow

# This is the commit message pygobject#8:

Update Gdk to 4.0

# This is the commit message pygobject#9:

Move Gdk into correct location

# This is the commit message pygobject#10:

Add types for Adw.Avatar

# This is the commit message pygobject#11:

Add types for Adw

# This is the commit message pygobject#12:

Removed Typing import

# This is the commit message pygobject#13:

Add types for Adw
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants