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

GTK in Windows: Typelib for HarfBuzz version '0.0' is not found #5129

Closed
5 of 6 tasks
danyeaw opened this issue Aug 30, 2020 · 1 comment · Fixed by #5133
Closed
5 of 6 tasks

GTK in Windows: Typelib for HarfBuzz version '0.0' is not found #5129

danyeaw opened this issue Aug 30, 2020 · 1 comment · Fixed by #5133

Comments

@danyeaw
Copy link
Contributor

danyeaw commented Aug 30, 2020

Description of the issue

Packaging Gtk apps in Windows with pyinstaller now gives an error that the Typelib for HarfBuzz version '0.0' is not found. Recent changes to Gtk/Pango are now including the typelib for HarfBuzz. I think we need to add a hook to include this typelib.

Steps to Reproduce the Problem

  1. Update msys2 and install pygobject:
$ pacman -Suy
$ pacman -S git mingw-w64-x86_64-gcc mingw-w64-x86_64-gtk3 \
mingw-w64-x86_64-pkg-config mingw-w64-x86_64-cairo \
mingw-w64-x86_64-gobject-introspection mingw-w64-x86_64-python \
mingw-w64-x86_64-python-gobject mingw-w64-x86_64-python-cairo \
mingw-w64-x86_64-python-pip
  1. python -m venv .venv
  2. source .venv/bin/activate
  3. pip install pygobject pyinstaller==3.6
  4. pyinstaller --exclude-module tk --exclude-module tcl --exclude-module _tkinter helloworld.py
  5. ./dist/helloworld/helloworld.exe
$ ./dist/helloworld/helloworld.exe
gi.RepositoryError: Typelib file for namespace 'HarfBuzz', version '0.0' not found

(see full stacktrace below)

Expected behavior:
Hello world PyGObject example runs fine when packaged with pyinstaller:

import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk

window = Gtk.Window(title="Hello World")
window.show()
window.connect("destroy", Gtk.main_quit)
Gtk.main()

Context information (for bug reports)

Make sure everything is packaged correctly

  • start with clean installation
  • use the latest development version
  • Run your frozen program from a command window (shell) — instead of double-clicking on it
  • Package your program in --onedir mode
  • Package without UPX, say: use the option --noupx or set upx=False in your .spec-file
  • Repackage you application in verbose/debug mode. For this, pass the option --debug to pyi-makespec or pyinstaller or use EXE(..., debug=1, ...) in your .spec file.

A minimal example program which shows the error

import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk

window = Gtk.Window(title="Hello World")
window.show()
window.connect("destroy", Gtk.main_quit)
Gtk.main()

Stacktrace / full error message

$ ./dist/helloworld/helloworld.exe
Traceback (most recent call last):
  File "gi/importer.py", line 138, in load_module
  File "gi/module.py", line 265, in get_introspection_module
  File "gi/module.py", line 117, in __init__
gi.RepositoryError: Typelib file for namespace 'HarfBuzz', version '0.0' not found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "helloworld.py", line 3, in <module>
    from gi.repository import Gtk
  File "gi/importer.py", line 140, in load_module
ImportError: Typelib file for namespace 'HarfBuzz', version '0.0' not found
[10892] Failed to execute script helloworld

Gtk now includes the typelib for HarfBuzz:

$ g-ir-inspect.exe Gtk --print-shlibs --print-typelibs
shlib: libgtk-3-0.dll
typelib: GLib-2.0
typelib: Gdk-3.0
typelib: HarfBuzz-0.0
typelib: GdkPixbuf-2.0
typelib: cairo-1.0
typelib: GObject-2.0
typelib: Pango-1.0
typelib: Gio-2.0
typelib: GModule-2.0
typelib: Atk-1.0

The shared library is libharfbuzz-gobject-0.dll:

$ g-ir-inspect.exe HarfBuzz --print-shlibs --print-typelibs
shlib: libharfbuzz-gobject-0.dll
typelib: GObject-2.0
typelib: GLib-2.0

Things I Have Tried So Far

I created a new hook called hook-gi.repository.HarfBuzz.py with:

from PyInstaller.utils.hooks import get_gi_typelibs

binaries, datas, hiddenimports = get_gi_typelibs('HarfBuzz', '0.0')

18021 WARNING: Hidden import "gi.repository.HarfBuzz" not found!

@danyeaw
Copy link
Contributor Author

danyeaw commented Aug 31, 2020

I was able to resolve this by creating a pre_safe and a normal hook. I will submit a PR to close this.

danyeaw added a commit to danyeaw/pyinstaller that referenced this issue Sep 1, 2020
Fixes pyinstaller#5129 which is an error for gi.RepositoryError: Typelib file for
namespace 'HarfBuzz', version '0.0' not found. The cause of this error
is that Gtk and Pango now include HarfBuzz-0.0 as a typelib that
needs to be loaded with the other libraries. This change adds hooks for
this typelib.
danyeaw added a commit to danyeaw/pyinstaller that referenced this issue Sep 1, 2020
Fixes pyinstaller#5129 which is an error for gi.RepositoryError: Typelib file for
namespace 'HarfBuzz', version '0.0' not found. The cause of this error
is that Gtk and Pango now include HarfBuzz-0.0 as a typelib that
needs to be loaded with the other libraries. This change adds hooks for
this typelib.
danyeaw added a commit to danyeaw/pyinstaller that referenced this issue Sep 1, 2020
Fixes pyinstaller#5129 which is an error for gi.RepositoryError: Typelib file for
namespace 'HarfBuzz', version '0.0' not found. The cause of this error
is that Gtk and Pango now include HarfBuzz-0.0 as a typelib that
needs to be loaded with the other libraries. This change adds hooks for
this typelib.
danyeaw added a commit to danyeaw/pyinstaller that referenced this issue Sep 1, 2020
Fixes pyinstaller#5129 which is an error for gi.RepositoryError: Typelib file for
namespace 'HarfBuzz', version '0.0' not found. The cause of this error
is that Gtk and Pango now include HarfBuzz-0.0 as a typelib that
needs to be loaded with the other libraries. This change adds hooks for
this typelib.
Legorooj pushed a commit that referenced this issue Sep 2, 2020
Fixes #5129 which is an error for gi.RepositoryError: Typelib file for
namespace 'HarfBuzz', version '0.0' not found. The cause of this error
is that Gtk and Pango now include HarfBuzz-0.0 as a typelib that
needs to be loaded with the other libraries. This change adds hooks for
this typelib.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant