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

py2app 0.64 fails to find sip from mac homebrew #35

Closed
ronaldoussoren opened this issue Jan 30, 2012 · 17 comments
Closed

py2app 0.64 fails to find sip from mac homebrew #35

ronaldoussoren opened this issue Jan 30, 2012 · 17 comments
Labels
bug Something isn't working

Comments

@ronaldoussoren
Copy link
Owner

Original report by Autobot (Bitbucket: acidjunk, GitHub: acidjunk).


When using py2app 0.63 everything works OK (building a 64 bit app for 10.6 & 10.7). With py2app 0.64 I'm getting this error when trying to build my app.


running py2app
creating /Users/acidjunk/Desktop/njoy/QTplayer/build
creating /Users/acidjunk/Desktop/njoy/QTplayer/build/bdist.macosx-10.4-x86_64
creating /Users/acidjunk/Desktop/njoy/QTplayer/build/bdist.macosx-10.4-x86_64/python2.7-standalone
creating /Users/acidjunk/Desktop/njoy/QTplayer/build/bdist.macosx-10.4-x86_64/python2.7-standalone/app
creating /Users/acidjunk/Desktop/njoy/QTplayer/build/bdist.macosx-10.4-x86_64/python2.7-standalone/app/collect
creating /Users/acidjunk/Desktop/njoy/QTplayer/build/bdist.macosx-10.4-x86_64/python2.7-standalone/app/temp
creating /Users/acidjunk/Desktop/njoy/QTplayer/dist
creating build/bdist.macosx-10.4-x86_64/python2.7-standalone/app/lib-dynload
creating build/bdist.macosx-10.4-x86_64/python2.7-standalone/app/Frameworks
*** using recipe: virtualenv ***
error: /usr/local/Cellar/python/2.7.2/Frameworks/Python.framework/Versions/2.7/share/sip: No such file or directory

I'm running OS X 10.7 with python and qt from homebrew. I tried the py2app 0.63 version because that's what I used on my old builder mac (OSX 10.6). I describe the old build environment here: http://www.renedohmen.nl/blog/2011/11/installing-pyqt4-on-mac-osx/

@ronaldoussoren
Copy link
Owner Author

Original comment by C.Y. Pang (Bitbucket: [Shuge Lee](https://bitbucket.org/Shuge Lee), ).


https://github.com/shuge/Enjoy-Qt-Python-Binding/tree/master/package_maker

@ronaldoussoren
Copy link
Owner Author

Original comment by Anonymous.


I don't know what I need to do with your URL. I don't like macports as it breaks to often. Homebrew is much easier and has better support for current OSX versions. I don't need a 32bit bin nor a PPC build; so building all the deps with homebrew is far easier to maintain and builds smaller apps for me.

For your information: a while ago I tried to install python27 with QT on OSX 10.6 with macports, but it failed, I can't work with python2.5 which is used in your example.

py2app 0.6.3 builds my app just fine on a mac with home brew python, qt and pyqt.
py2app 0.6.4 doesn't build it; because it fails to find sip package (on macports location)

@ronaldoussoren
Copy link
Owner Author

Original comment by Anonymous.


I managed to get this working with a quick and dirty link:

ln -s /usr/local/lib/python /usr/local/Cellar/python/2.7.2/Frameworks/Python.framework/Versions/2.7/share/sip

-TP

@ronaldoussoren
Copy link
Owner Author

Original comment by Autobot (Bitbucket: acidjunk, GitHub: acidjunk).


'll try the simple symlink solution tomorrow on a virgin OS 10.7

@ronaldoussoren
Copy link
Owner Author

Original comment by Autobot (Bitbucket: acidjunk, GitHub: acidjunk).


On my, not so clean 10.7 system I dind't have a /usr/local/lib/python:
So I did:
ln -s /usr/local/lib/python2.7 /usr/local/Cellar/python/2.7.2/Frameworks/Python.framework/Versions/2.7/share/sip

py2app worked fine after that.

Still I think this is a small bug in py2app 0.6.4 because py2app 0.6.3 just works fine without the symlink.
It should look in the correct site-packages, if python from homebrew is installed and used to build the app.

@ronaldoussoren
Copy link
Owner Author

Original comment by Michael McCracken (Bitbucket: mikemccracken, GitHub: mikemccracken).


I just ran into this too - so I poked at it a bit:

NOTE: this is on 10.6.8.

py2app is using sip's config variable "default_sip_dir" - which SIP's docs say is the default place for .sip specification files.

We get this error because --sipdir is not being sent to SIP's configure in the homebrew recipe:
https://github.com/mxcl/homebrew/blob/master/Library/Formula/sip.rb#L34
If someone wants to change that there, they're welcome to. (but I don't think that's the real issue)

The reason the symlink hack above works is that there appear to be no .sip spec files installed or used by default, so it's OK to have an empty directory - we're not missing anything.

However, it doesn't look like the code is only expecting to get .sip files from that dir, it's expecting to get python packages.
At first I thought it was using the wrong sip config variable, and should use 'sip_mod_dir' instead of 'default_sip_dir', so I tried that change.
On my system sip_mod_dir is /usr/local/Cellar/sip/4.13.2/lib/python2.6/site-packages, which has sip.so, sipconfig.py, and sipdistutils.py (and nothing else)

That doesn't give us the error anymore at build time but doesn't work at runtime.
So looking at the SIP recipe - it's actually expecting to see the PyQt4 files at that dir.
On my system, they're in /usr/local/Cellar/pyqt/4.9.1/lib/python2.6/site-packages/PyQt4/, which is accessible via cfg.pyqt_mod_dir -- but using this doesn't work, and while hacking around trying to make it work I realized I didn't really understand what the py2app SIP recipe is looking for in the code that goes through 'sipdir'. what's in that directory on non-homebrew systems?

Can anyone enlighten me? I will keep working on this but I wouldn't mind some help.

@ronaldoussoren
Copy link
Owner Author

Original comment by Ronald Oussoren (Bitbucket: ronaldoussoren, GitHub: ronaldoussoren).


The Qt recipe was written using notes from a py2app user that only used the Qt binary installer. I've adapted it for later editions of Qt without fully understanding how Qt and sip actually work.

IIRC it assumes that the top-level files/directories it finds in the SIP repository are the names of Python packages, all of which are copied into the application bundle because it is impossible to automatically detect dependencies for modules wrapped using sip. PyQt4 is treated specially because it is a nested package, the actual SIP wrappers are in sub packages of PyQt4.

To rephrase, the SIP recipe looks in the SIP repository for libraries that are wrapped using SIP and than adds those names to the list of python packages that should be excluded in the application bundle.

@ronaldoussoren
Copy link
Owner Author

Original comment by Sebastian Krysmanski (Bitbucket: skrysmanski, GitHub: skrysmanski).


I guess, the solution is to check whether the sip directory actually exists. Here's the changed code (for file ##/Library/Python/2.7/site-packages/py2app/recipes/sip.py## starting in line ##47## ):

#!python
        sipdir = cfg.default_sip_dir
        self.packages = set()

        if os.path.exists(sipdir):
            for fn in os.listdir(sipdir):
                fullpath = os.path.join(sipdir, fn)
                if os.path.isdir(fullpath):
                    self.packages.add(fn)
                    if fn == 'PyQt4':
                        # PyQt4 has a nested structure, also import
                        # subpackage to ensure everything get seen.
                        for sub in os.listdir(fullpath):
                            self.packages.add('%s.%s'%(fn, sub))
                
        self.warn = cfg.qt_edition == 'free'
        return self.packages

@ronaldoussoren
Copy link
Owner Author

Original comment by Michael McCracken (Bitbucket: mikemccracken, GitHub: mikemccracken).


@skrysmanski, that wasn't enough for me - just ignoring a missing default sip dir avoids the missing directory error but also won't find the PyQt modules the function is looking for.

I ended up using a different PyQt config variable to find the modules that we want.

I put the changes that did work for me in a fork and sent a pull request.

There's one tweak - if you really need the 'uic' module and you're running python2, my solution won't work for you easily, because uic has some py3 code that uses the new metaclass= keyword syntax, which py2 won't parse.

I suppose we could tell modulefinder just not to look at that part of uic. But I don't use uic so I just ignored all of it in my setup.py, and added a warning in my patch.

NOTE:

The patch I mentioned may not entirely work, after fixing an unrelated problem that stopped me from testing it, I find that my app is loading two versions of Qt and crashing - so I removed my pull request and will keep working on it in my private fork.

@ronaldoussoren
Copy link
Owner Author

Original comment by Michael McCracken (Bitbucket: mikemccracken, GitHub: mikemccracken).


Final comment: the patch does work for me, so I re-created the pull request.

The multiple Qt version problem is separate, it's about Qt plugins and can be fixed by 'touch MyApp.app/Contents/Resources/qt.conf'.
I've written more on the pythonmac-sig mailing list about plugins.

@ronaldoussoren
Copy link
Owner Author

Original comment by Frank Spano (Bitbucket: mrmuler, ).


I'm having the same problem, I Installed PyQt from the PyQtX project.
I'm still a novice when it comes to dev on MacOsX, and I feel a little lost.

My application runs perfectly from the py file, but for some reason I get that sip error when I try to build my app.

The reason is evident, there is no such directory, buy why??? Am I missing something??

error: /Library/Frameworks/Python.framework/Versions/2.7/share/sip: No such file or directory

@ronaldoussoren
Copy link
Owner Author

Original comment by Autobot (Bitbucket: acidjunk, GitHub: acidjunk).


Did you try the symlink option? From Anonymous at 2012-02-14

@ronaldoussoren
Copy link
Owner Author

Original comment by Frank Spano (Bitbucket: mrmuler, ).


No success...

ln -s /usr/local/lib/python /Library/Frameworks/Python.framework/Versions/2.7/share/sip/

ln: /Library/Frameworks/Python.framework/Versions/2.7/share/sip/: No such file or directory

I don't know if I did it right. Correct me if im wrong please

@ronaldoussoren
Copy link
Owner Author

Original comment by Autobot (Bitbucket: acidjunk, GitHub: acidjunk).


I didn't follow the bug for a while now. Because I had a working setup with py2app 0.6.3. I also have a VMARE image with a working setup for OSX 10.7 & PyQT 4.9 / Python 2.7.3. So I don't know if the above patch will work you. Nor do I know enough about you current setup.

When I created the ticket I was running (Py)QT and Python from home brew. To make sure the build system had everything needed to distribute the app I installed all deps from homebrew and used python from homebrew also. I didn't know or use PyQTX; but compiled and installed pyqt with homebrew.

@ronaldoussoren
Copy link
Owner Author

Original comment by Frank Spano (Bitbucket: mrmuler, ).


I managed to find the dir and install manually the sip files from the repo, made the ln and that made it. but now I'm stuck with another issue. :S

when I try to execute the application from the //dist// folder I get an error.

10/4/12 3:32:11.506 AM window_ui_latest2[27344]: window_ui_latest2 Error
10/4/12 3:32:13.791 AM com.apple.launchd.peruser.501[135]: ([0x0-0x215014e].org.pythonmac.unspecified.window_ui_latest2[27344]) Exited with code: 255

does it sound familiar to any of you??? (just asking before I create a ticket)

@ronaldoussoren
Copy link
Owner Author

Original comment by Ronald Oussoren (Bitbucket: ronaldoussoren, GitHub: ronaldoussoren).


See also issue #18.

As of today the tip of the tree contains much improved support for PyQt. I'd love to know if this work, and the earlier work by Micheal McCracken on the sip recipe, fixes the problems mentioned in this issue.

Could you please this if the tip of the tree fixes the issue for you?

@ronaldoussoren
Copy link
Owner Author

Original comment by Ronald Oussoren (Bitbucket: ronaldoussoren, GitHub: ronaldoussoren).


I'm assuming this issue has been fixed in the 0.7 release, please open a new issue when there are still Qt issues.

@ronaldoussoren ronaldoussoren added major bug Something isn't working labels Jan 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant