Hi there,

I am going to ask for your ideas on how to get PyInstaller to properly 
package a project with PyObjc.

My project uses PyObjC in a very small part, the rest of the project is 
entirely free of any dependencies. I can successfully package my project 
without the PyObjC part, so I am certain that the fragment of code given 
below are the entirety of my PyObjC code and dependency.

import  objc
from AppKit import NSObject

class NSObjCApp(NSObject):

    @objc.signature('B@:#B')
    def applicationShouldHandleReopen_hasVisibleWindows_(self, nsAppObject, 
flag):
        app.onClickOnDock()
        return True

cls = objc.lookUpClass('NSApplication')
appInstance = cls.sharedApplication() # I'm doing some real crazy runtime 
shit there.
ta = NSObjCApp.alloc().init()
appInstance.setDelegate_(ta)

When I package my app, I receive this:

Traceback (most recent call last):
  File "<string>", line 55, in <module>
ImportError: cannot import name NSObject

I have both AppKit and pyobjc as hidden imports in my spec. It does not fix 
the issue. I am not receiving any errors in packaging phase about AppKit 
and pyobjc, they are being found and imported. I can also see their 
existence as .so modules, as well a few other core foundation modules.

I have found this project on Github that patched both of the libraries to 
work with one another:

https://github.com/Fitblip/PyObjC-PyInstaller

And the patches they did can be found here:

https://github.com/Fitblip/PyObjC-PyInstaller/tree/master/patches

As you can see, the patches are quite trivial. They are adding 
.bridgesupport files for the PyObjC libraries as data. I however could not 
get this to work, as it more than one year old, and the version of 
PyInstaller they are using has numerous problems with both itself and macho 
libraries. I tried to fix them best as I could, but I got stuck at PyQt 
imports: even if I copy over the pyqt5 hooks from a newer pyinstaller, it 
does not work correctly. So this repository, I am only taking it as a proof 
that PyInstaller and PyObjC was once possible.

As a second step, I tried to add this patch to newest pyinstaller stable 
and dev, and newest PyObjC available on pip. These are run in a virtualenv, 
so they do not interact with system's buggy (or said to be) PyObjC 
installation. These modifications failed to produce a different result. I 
also tried to patch system's own PyObjC, which was also fruitless.

So I'm stuck here. Clicking on dock is a rather important UI action that I 
want to provide to my users, so I have to work with PyObjC somehow.

Any directions?

Regards,
Burak






-- 
You received this message because you are subscribed to the Google Groups 
"PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pyinstaller.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to