Comments you submit will be routed for moderation. If you have an account, please log in first.
Modify

Ticket #584 (closed defect: fixed)

Opened 11 months ago

Last modified 8 weeks ago

MacOSX Lion: wxPython program skips packing of Python shared library

Reported by: a_villacis Owned by: matysek
Priority: normal Milestone: PyInstaller 2.1
Component: Platform Mac Version: develop
Severity: normal Keywords: mac wx
Cc:

Description

I have a small wxPython script that I want to package. Before using pyinstaller, I verified that I can run the program correctly in both Windows, Fedora 16, and MacOSX Lion.

On WindowsXP, the packaging works normally, with or without wxPython. On MacOSX Lion, a script that does not import wxPython is also packaged normally, in either one-file mode or one-dir mode. When wxPython is installed (wxPython2.8-osx-unicode-2.8.12.1-universal-py2.7.dmg from official wxPython website), and I try to package a script that uses wxPython, the packaging apparently runs normally, but when I attempt to run the resulting package (in either one-file or one-dir mode), I get:

Python library not found. Bus error 10

The difference is that when the script imports wxPython, pyinstaller forgets to include the 'Python' shared library, which does appear when the packaged script does not use wxPython.

I am running the packager with this command line: VERSIONER_PYTHON_PREFER_32_BIT=yes arch -i386 python pyinstaller-gui.py

I have tried the development package from www.pyinstaller.org, as well as a checkout of the latest git, and both show the bug.

If I copy manually /System/Library/Frameworks/Python?.framework/Versions/2.7/Python to the one-dir directory, the app no longer shows the missing library error, but I get this instead:

This program needs access to the screen. Please run with 'pythonw', not 'python', and only when you are logged in on the main display of your Mac.

I tried setting LSBackgroundOnly to 0 in PyInstaller?/build.py, but it had no effect.

Attachments

Change History

comment:1 Changed 11 months ago by matysek

  • Severity changed from blocker to normal

First of all, do not use 'pyinstaller-gui.py' and use '--windowed' option.

comment:2 Changed 11 months ago by matysek

Does it happen only with wxPython or even without it? Please provide small code example for reproduction of your issue.

comment:3 Changed 11 months ago by a_villacis

Thanks for the --windowed tip. I added it to the invocation of pyinstaller.py, and the "This program needs access to the screen..." message does not appear anymore. However, I still have to copy the 'Python' shared library manually, or I get the 'not found' message.

This issue happens only on programs that use wxPython. As I mentioned before, a python program that does not use wxPython gets packaged normally into a working executable or directory.

The minimal wxPython program that exhibits the bug:

#!/usr/bin/python

import wx

a = wx.App()
f = wx.Frame(None, -1, "Test")
f.Show(True)
a.SetTopWindow(f)
a.MainLoop()

comment:4 Changed 11 months ago by matysek

  • Milestone set to PyInstaller 2.1

That's really weird.

comment:5 Changed 9 months ago by anonymous

Is this really the way it suppose to work? By the what could mean error fatal error access to undeclared static property ?

comment:6 Changed 4 months ago by anonymous

I believe this is because wxPython only works in 32-bit mode and the default arch is 64-bit for OS X Python. You'll need to create a 32-bit version of Python and then run pyinstaller.py with the 32-bit version:

To make a 32-bit version of Python:

lipo -thin i386 -output python-i386 /usr/bin/python2.7

Then run:

./python-i386 /path/to/pyinstaller.py --windowed --onefile myapp.py

It should then work as expected.

comment:7 Changed 8 weeks ago by stefan.hong@…

Same problem here. I use 64-bit wxPython 2.9 because I want to use Cocoa rather than Carbon. This is the output when building the minimal wxPython program mentioned above:

$ python ~/bin/pyinstaller-2.0/pyinstaller.py --windowed --onefile hello.py
15 INFO: wrote /Users/stefan/tmp/foo/hello.spec
46 WARNING: You are running 64-bit Python: created binaries will only work on Mac OS X 10.6+.
If you need 10.4-10.5 compatibility, run Python as a 32-bit binary with this command:

    VERSIONER_PYTHON_PREFER_32_BIT=yes arch -i386 /usr/bin/python

4058 INFO: UPX is not available.
5282 INFO: checking Analysis
5282 INFO: building Analysis because out00-Analysis.toc non existent
5282 INFO: running Analysis out00-Analysis.toc
5294 INFO: Analyzing /Users/stefan/bin/pyinstaller-2.0/support/_pyi_bootstrap.py
6503 INFO: Analyzing /Users/stefan/bin/pyinstaller-2.0/PyInstaller/loader/archive.py
6586 INFO: Analyzing /Users/stefan/bin/pyinstaller-2.0/PyInstaller/loader/carchive.py
6672 INFO: Analyzing /Users/stefan/bin/pyinstaller-2.0/PyInstaller/loader/iu.py
6697 INFO: Analyzing hello.py
7312 INFO: Hidden import 'encodings' has been found otherwise
7312 INFO: Looking for run-time hooks
7312 INFO: Analyzing rthook /Users/stefan/bin/pyinstaller-2.0/support/rthooks/pyi_rth_encodings.py
8020 INFO: Warnings written to /Users/stefan/tmp/foo/build/pyi.darwin/hello/warnhello.txt
8031 INFO: checking PYZ
8031 INFO: rebuilding out00-PYZ.toc because out00-PYZ.pyz is missing
8031 INFO: building PYZ out00-PYZ.toc
9044 INFO: checking PKG
9044 INFO: rebuilding out00-PKG.toc because out00-PKG.pkg is missing
9044 INFO: building PKG out00-PKG.pkg
34394 INFO: checking EXE
34394 INFO: rebuilding out00-EXE.toc because hello missing
34394 INFO: building EXE from out00-EXE.toc
34424 INFO: Appending archive to EXE /Users/stefan/tmp/foo/dist/hello
34536 INFO: checking BUNDLE
34536 INFO: building BUNDLE out00-BUNDLE.toc
$

The build seems successful, but the generated binary doesn't work:

$ ls dist
hello*     hello.app/
$ ./dist/hello
Python library not found.
Segmentation fault: 11
$ ./dist/hello.app/Contents/MacOS/hello
Python library not found.
Segmentation fault: 11
$

comment:8 Changed 8 weeks ago by matysek

Could you please try to use latest development version if the issue is fixed there?

Thanks.

comment:9 follow-up: ↓ 10 Changed 8 weeks ago by stefan.hong@…

Ok I just tried to use the latest development version, and it works! Awesome.

Is the latest development version stable enough to use in the production environment?

comment:10 in reply to: ↑ 9 Changed 8 weeks ago by matysek

  • Status changed from new to closed
  • Resolution set to fixed

Replying to stefan.hong@…:

Ok I just tried to use the latest development version, and it works! Awesome.

Is the latest development version stable enough to use in the production environment?

It should be stable enough. It is in the stabilization phase and it should almost reflect the state for next release.

Thanks for testing.

View

Add a comment

Modify Ticket

Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.