Re: [gtk-osx-users] GTK-Mac-Bundler lib changes.





On Jun 9, 2020, at 2:44 AM, Pascal <p p14 orange fr> wrote:


Le 8 juin 2020 à 18:13, John Ralls <jralls ceridwen us> a écrit :



On Jun 8, 2020, at 3:03 AM, Pascal <p p14 orange fr> wrote:


Le 7 juin 2020 à 19:39, Pascal <p p14 orange fr> a écrit :

Hello,

I've used gtk-mac-bundler to create my app, but I've some issues with referenced dylib.

GTK libs are referenced with absolute path:
<prefix>/lib/libgtk-3.0.dylib
These are changed by gtk-mac-bundler into:
@executable_path/../Resources/lib/libgtk-3.0.dylib

I've got some messages as:
Cannot find a matching prefix for libxmlada_schema.dylib
These libs are outside <prefix>/lib so I changed them to absolute path.

However, I have other libs built in <prefix>/lib that are referenced with relative path, for instance:
@rpath/libadalang.dylib
These are not changed by gtk-mac-bundler so I've added rpath "@executable_path/../Resources/lib" and 
I've deleted all rpath with <prefix>/lib in executable and all libs.
I've checked with otool that the only remaining rpath is "@executable_path/../Resources/lib".

But when executing the app I've messages for instance:
objc[45002]: Class GdkQuartzView is implemented in both 
/opt/gps-build/osx_bundle/_build/Applications/gnatstudio.app/Contents/Resources/lib/libgdk-3.0.dylib 
(0x113f0a960) and /opt/xnadalib-2020/lib/libgdk-3.0.dylib (0x11ed97960). One of the two will be used. 
Which one is undefined.

I do not understand where there are these references to  <prefix>/lib (/opt/xnadalib-2020/lib in my 
case).
Any idea is welcome.

I've gone further, the references of <prefix>/lib are coming from *.so in lib/Python2.7.
I had just put in my bungle file:
<data>
 ${prefix}/lib/python2.7
</data>

So I changed for:
<binary>
 ${prefix}/lib/python2.7/lib-dynload/*.so
</binary>
<binary>
 ${prefix}/lib/python2.7/site-packages/*.so
</binary>
<binary>
 ${prefix}/lib/python2.7/site-packages/gi/*.so
</binary>
<binary>
 ${prefix}/lib/python2.7/site-packages/cairo/*.so
</binary>

Side question, I've manually copied the *.py files to prevent to overwrite the modified *.so files, is 
there a way to do it safely in the bundle file?

Then I've a issue with gi:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File 
"/opt/gps-build/osx_bundle/_build/Applications/gnatstudio.app/Contents/Resources/lib/python2.7/site-packages/gi/__init__.py",
 line 129, in require_version
 raise ValueError('Namespace %s not available' % namespace)
ValueError: Namespace Gtk not available

What could be missing in the bundle file?

The typelibs?

I don't understand what you mean about manually copying the python files to prevent overwriting the 
loadable modules. How would that happen?

You might look at https://github.com/gramps-project/gramps/blob/maintenance/gramps51/mac/gramps.bundleto 
see how I bundle Gramps.

Regards,
John Ralls

Thanks John for your exemple :-)

Especially nice tips:  recurse="True" and the gir section.

Now for Python files, I can do:
 <binary recurse="True">
   ${prefix}/lib/python2.7/*.so
 </binary>
and
 <data recurse="True">
   ${prefix}/lib/python2.7/*.py
 </data>

I've got many:
"Error in transformation of /opt/xnadalib-2020/share/gir-1.0/xlib-2.0.gir: 'encoding' is an invalid keyword 
argument for this function"

With traceback in project.py:
TypeError: 'encoding' is an invalid keyword argument for this function
Error in transformation of /opt/xnadalib-2020/share/gir-1.0/GtkosxApplication-1.0.gir: 'encoding' is an 
invalid keyword argument for this function
Traceback (most recent call last):
 File "/opt/gtk-mac-bundler.0/bundler/project.py", line 413, in copy_target
   typelib_paths.append(transform_file(globbed_source))
 File "/opt/gtk-mac-bundler.0/bundler/project.py", line 389, in transform_file
   with open (filename, "r", encoding="utf8") as source:

Thus, I removed the encoding parameter:
--- ./bundler/project.py.0    2020-06-09 10:25:20.000000000 +0200
+++ ./bundler/project.py      2020-06-09 10:27:08.000000000 +0200
@@ -386,11 +386,11 @@
            path, fname = os.path.split(filename)
            name, ext = os.path.splitext(fname)

-            with open (filename, "r", encoding="utf8") as source:
+            with open (filename, "r") as source:
                lines = source.readlines()
            gir_file = os.path.join(gir_dest, fname)
            typelib = os.path.join(typelib_dest, name + '.typelib')
-            with open (gir_file, "w", encoding="utf8") as target:
+            with open (gir_file, "w") as target:
                for line in lines:

I also add GI_TYPELIB_PATH and now it works almost fine:
some macOS keyboard shortcuts are not working :-(
Any idea?

Pascal,

Something else is wrong. `encoding` *is* a legal parameter to `open`: 
https://docs.python.org/3/library/functions.html#open

As for keyboard shortcuts, it depends on what shortcuts you mean. If it's something like ctrl vs. command 
make sure that you use GDK_MODIFIER_INTENT_PRIMARY_ACCELERATOR instead of GDK_CONTROL_MASK. If you use 
accelerator groups other keys can be customized with an accelerator map file; if not you'll have to hand-code 
them one by one.

OTOH if you want to use the keybindings from system preferences you'll have to code that yourself, AFAIK Gtk 
doesn't do that.

Regards,
John Ralls



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