Issue #35 resolved

py2app 0.64 fails to find sip from mac homebrew

acidjunk avataracidjunk created an issue

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/

Comments (17)

  1. 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)

  2. 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

  3. 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.

  4. Michael McCracken

    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.

  5. Ronald Oussoren

    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.

  6. Sebastian Krysmanski

    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 ):

            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
    
  7. Michael McCracken

    Sebastian Krysmanski, 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.

    - Michael McCracken

  8. Frank Spano

    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

  9. Frank Spano

    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

  10. 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.

  11. Frank Spano

    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)

  12. Ronald Oussoren

    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?

  13. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.