1

I'm using OS X Lion (10.7.3) and I'm trying to write a cross-platform, stand-alone GUI-based program using wxPython and py2app.

I tried to use Python 2.7.1 which comes shipped with Lion.

I got the wxPython2.8 binaries (wxPython2.8-osx-unicode-py2.7).

I installed py2app via pip.

This is my little test app:

#!/usr/bin/python
import wx
app = wx.App()
frame = wx.Frame(None, -1, 'test.py')
frame.Show()
app.MainLoop()

This is my setup.py:

from setuptools import setup
setup(
    app=["test.py"],
    setup_requires=["py2app"],
)

wxPython 2.8 wants 32-bit mode, so I use the arch command:

arch -i386 /usr/bin/python2.7 test.py

How do I tell py2app to use/include 32bit Python?

It is possible to manually exchange the relevant files in the app bundle, but that's a rather clumsy workaround. I could also use 64bit wxPython2.9, but there isn't a stable release available yet. Should I switch to cx_Freeze? What is the best practice here?

4

1 に答える 1

0

64ビットのPythonがインストールされている場合は、64ビットのアプリケーションが作成されます。
32ビットPythonがインストールされている場合は、32ビットアプリケーションが作成されます。

両方をインストールした場合、作成される内容は、Pythonがライブラリを収集する場所(32ビットまたは64ビットのインストールフォルダー)によって異なります。
Windowsでは、これは実際に実行されているPython実行可能ファイルによって異なります。そしてこれは、システムまたはユーザーのPATH設定の最初にあるものによって異なります。

python setup.pyと入力すると、Windowsはpython.exeを実行しますが、コマンドラインから実行されるpython.exeは、PATHenvironemnt変数によって異なりますエクスプローラーでsetup.pyをダブルクリックした場合に実行されるのは、 .pyファイルとのファイルの関連付けによって異なります。

任意のインスタンス内から32ビットのPythonインスタンスを生成することで、setup.pyが正しく実行されていることを簡単に確認できます。

于 2012-05-07T15:42:17.557 に答える