[gtk-osx-users] Need to explicitly export DYLD_FALLBACK_LIBRARY_PATH



Hello, I followed the build instructions on the wiki and everything's built correctly. However my application fails to run with a warning about libpango-1.0.0.dylib not being found and then a traceback. I can narrow it down to just doing a `from gi.repository import Gtk`.

    bash-3.2$ python3
    Python 3.6.8 (default, Sep 24 2019, 17:23:22)
    [GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.2)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from gi.repository import Gtk

    ** (process:45468): WARNING **: 20:30:34.767: Failed to load shared library 'libpango-1.0.0.dylib' referenced by the typelib: dlopen(libpango-1.0.0.dylib, 9): image not found
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "<frozen importlib._bootstrap>", line 971, in _find_and_load
      File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 656, in _load_unlocked
      File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible       File "/Users/gtk3/gtk/inst/lib/python3.6/site-packages/gi/importer.py", line 145, in load_module
        importlib.import_module('gi.repository.' + dep.split("-")[0])
      File "/Users/gtk3/gtk/inst/lib/python3.6/importlib/__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 994, in _gcd_import
      File "<frozen importlib._bootstrap>", line 971, in _find_and_load
      File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 656, in _load_unlocked
      File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible       File "/Users/gtk3/gtk/inst/lib/python3.6/site-packages/gi/importer.py", line 145, in load_module
        importlib.import_module('gi.repository.' + dep.split("-")[0])
      File "/Users/gtk3/gtk/inst/lib/python3.6/importlib/__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 994, in _gcd_import
      File "<frozen importlib._bootstrap>", line 971, in _find_and_load
      File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 656, in _load_unlocked
      File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible       File "/Users/gtk3/gtk/inst/lib/python3.6/site-packages/gi/importer.py", line 146, in load_module
        dynamic_module = load_overrides(introspection_module)
      File "/Users/gtk3/gtk/inst/lib/python3.6/site-packages/gi/overrides/__init__.py", line 118, in load_overrides
        override_mod = importlib.import_module(override_package_name)
      File "/Users/gtk3/gtk/inst/lib/python3.6/importlib/__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "/Users/gtk3/gtk/inst/lib/python3.6/site-packages/gi/overrides/Pango.py", line 41, in <module>
        FontDescription = override(FontDescription)
      File "/Users/gtk3/gtk/inst/lib/python3.6/site-packages/gi/overrides/__init__.py", line 195, in override
        assert g_type != TYPE_NONE
    AssertionError


Explicitly setting DYLD_FALLBACK_LIBRARY_PATH seems to fix the problem:

    bash-3.2$ export DYLD_FALLBACK_LIBRARY_PATH=/Users/gtk3/gtk/inst/lib
    bash-3.2$ python3
    Python 3.6.8 (default, Sep 24 2019, 17:23:22)
    [GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.2)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from gi.repository import Gtk

    (.:45493): Gtk-WARNING **: 20:33:47.938: Locale not supported by C library.
        Using the fallback 'C' locale.
    __main__:1: 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.


However the same problem happens when I bundle the application. Again, only doing the GTK import in the myapp_launcher.py file gives the same error (launcher file taken from gtk-mac-bundler example and Gramps for the updated version).

It already has `environ['DYLD_LIBRARY_PATH'] = bundle_lib`, but even adding `environ['DYLD_FALLBACK_LIBRARY_PATH'] = bundle_lib` makes no differences. Printing `bundle_lib` points to the lib dir inside the bundle and printing `os.path.exists(bundle_lib, 'libpango-1.0.0.dylib')` shows the file is actually there. So it's not picking up the Python set env variable.

It's only after I do `export DYLD_FALLBACK_LIBRARY_PATH=/path/to/myapp_bundle.app/Contents/Resources/lib` that the bundled app will run, but is of course only feasible to do on my dev machine.

Is it my environment that's tainted somehow? Did the build not correctly pick up paths?

Timo


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]