[Pythonmac-SIG] py2app sip recipe and Qt plugins

2009-09-19 Thread Marc-Antoine Parent

Good day!
I was trying my hand at wrapping a PyQt application, and I stumbled on  
the plugin issue that seems to have plagued many here, where the  
plugins load another copy of the Qt frameworks, indicated as such:


On Mac OS X, you might be loading two sets of Qt binaries into the  
same process. Check that all plugins are compiled against the right Qt  
binaries. Export DYLD_PRINT_LIBRARIES=1 and check that only one set of  
binaries are being loaded.


I looked a bit at how to fix this, and here is what worked for me. I  
have not yet written code to automate this process; but this  
description may be useful to people willing to fix executables by hand.


a) copy the plugin directory from /Developer/Applications/Qt/plugins  
to dist//Contents/plugins


b) Create a file dist//Contents/Resources/qt.conf
with contents as follows:
[Paths]
qt_plugpath=plugins

The path is relative to Contents. Another path could be chosen, that  
could be more congenial to py2app.


c) Adjust the paths of the plugins with install_name_tool. Eg, from  
the shell:


find dist//Contents/plugins -type f -exec  
install_name_tool -change QtGui.framework/Versions/4/QtGui  
@executable_path/../Frameworks/QtGui.framework/Versions/4/QtGui  {} ';'
find dist//Contents/plugins -type f -exec  
install_name_tool -change QtGui.framework/Versions/4/QtCore  
@executable_path/../Frameworks/QtCore.framework/Versions/4/QtCore  {}  
';'

(and so on if you need QtWebKit etc.)

Cheers,
Marc-Antoine Parent

___
Pythonmac-SIG maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/pythonmac-sig


Re: [Pythonmac-SIG] Pythonmac-SIG Digest, Vol 77, Issue 16

2009-09-19 Thread Edward Hartley


On 14 Sep 2009, at 16:05, [email protected] wrote:


Send Pythonmac-SIG mailing list submissions to
[email protected]

To subscribe or unsubscribe via the World Wide Web, visit
http://mail.python.org/mailman/listinfo/pythonmac-sig
or, via email, send a message with subject or body 'help' to
[email protected]

You can reach the person managing the list at
[email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Pythonmac-SIG digest..."
Today's Topics:

  1. Re: Pythonmac-SIG Digest, Vol 77, Issue 15 (Geert Dekkers)
  2. Re: Pythonmac-SIG Digest, Vol 77, Issue 15 (Geert Dekkers)

From: Geert Dekkers 
Date: 14 September 2009 15:44:06 BST
To: [email protected]
Subject: Re: [Pythonmac-SIG] Pythonmac-SIG Digest, Vol 77, Issue 15


Thanks David. As you suggested, I did a "file" on a python  
executable, and found that while you are quite correct that python  
is compiled a 2 way binary on a client 10.5, it's already a 4 way  
binary on the new xserve I have running 10.5  even though it's  
version 2.5. I also discovered that pyobjc will not automatically  
build as a 4 way bin against a 4 way build of python, and if you  
force it to, (by re-issuing a gcc command adding arch flags for 64  
bit ppc and intel) it will complain about a missing architecture in  
*.o file.


Mostly and I'm working from memory here to make PIL work effectively  
on 2.0 Python forward you need both numeric and IIRC ImageMagick and  
Jpeglib.
This has gone through several transitions s since I was actively using  
it.
It is worth installing and works very well particularly since you can  
get the PIL image in and out of numeric nicely.
Again from memory you need the third party jpeglib and not the OS X  
installed  one.

HTH
Ed Hartley


I'll try doing a python 2.6 build next, and go from there.

Geert


On 14/09/2009, at 12:00 PM, [email protected] wrote:


From: David Warde-Farley 
Date: 14 September 2009 9:48:02 AM
To: Pythonmac-Sig 3 
Subject:


On 13-Sep-09, at 10:58 AM, Geert Dekkers wrote:

The problem is of course that I need to coax PyObjC to be run by 64  
bit Apache. I read about the ability for PyObjC to run in 64-bit  
mode athttp://pyobjc.sourceforge.net/documentation/pyobjc-core/news.html 
. I don't know where to find out if my python is built with the  
required MACOSX_DEPLOYMENT_TARGET=10.5, but I would think so (as  
I'm running 10.5.8). (And you must realise I'm no hard-core  
programmer -- I learn as I go -- make heaps of mistakes doing so)


I did try a few tricks to get pyobjc to build as full fat binary  
(that is -arch ppc -arch i386 -arch ppc64 -arch x86_64) but so far  
no joy.


type="cite">(Actually one of the results was quite discerning: an  
example "ld warning: in build/temp.macosx-10.5-i386-2.5/Modules/ 
_sortandmap.o, missing required architecture ppc64 in file
ld warning: in build/temp.macosx-10.5-i386-2.5/Modules/ 
_sortandmap.o, missing required architecture x86_64 in file")


Neither the Python 2.5 shipped with Leopard nor the Python 2.5 at  
Python.org are 64-bit builds/include 64 bit support. Try running  
'file' on the python executable, you'll see only i386 and ppc.


You'll have to build a Python framework build from source as a 4-way  
universal (I'd recommend 2.6, as there is a script in the  
distribution for doing this on the Mac, and it might not even be  
possible on 2.5). Then you'll be able to build 4-way PyObjC (in  
fact, it should build that way automatically I think).


And I'm wondering if this is at all necessary. Because -- why can  
Apache run PIL? ?? -- th full fat, but you can indeed do "import  
Image"


dekkers-2:~ geert$ file /Library/Python/2.5/site-packages/PIL/ 
_imaging.so
/Library/Python/2.5/site-packages/PIL/_imaging.so: Mach-O universal  
binary with 2 architectures
/Library/Python/2.5/site-packages/PIL/_imaging.so (for architecture  
i386):	Mach-O bundle i386
/Library/Python/2.5/site-packages/PIL/_imaging.so (for architecture  
ppc7400):	Mach-O bundle ppc


But if you do "import _imaging", Apache gives you: "Could not  
import ccnet.views. Error was: dlopen(/Library/Python/2.5/site- 
packages/PIL/_imaging.so, 2): no suitable image fo und. Did 5/site- 
packages/PIL/_imaging.so: no matching architecture in universal  
wrapper"



My best guess (as I've never poked around in the guts of PIL) is  
that there is a pure Python version that is slow-as-molasses and  
then a sped up C version which is used if possible (_imaging.so).  
PIL invoked from Apache will thus probably use the slow-as-molasses  
version as the import of _imaging will silently fail somewhere in  
the Python code but be caught by an exception handler.


David





From: Geert Dekkers 
Date: 14 September 2009 16:05:13 BST
To: [email protected]
Subject: Re: [Pythonmac-SIG] Pythonmac-SIG Digest, Vol 77, Issue 15


UPDATE: Sorry, I was wrong. Cl

Re: [Pythonmac-SIG] machine architecture 32/64 with Python 2.6 on Snow Leopard?

2009-09-19 Thread Edward Moy
I looked into the code for platform.architecture(), and it basically  
runs the "file" command on /usr/bin/python.  If the output contains  
the string "64-bit", it will return "64bit" as the first tuple.  So it  
depends on what real question you are trying to answer, because in  
SnowLeopard, /usr/bin/python is a wrapper program that does all the  
versioning, reading preference files, etc, and is independent of the  
real python executable: /System/Library/Frameworks/Python.framework/ 
Versions/2.6/Resources/Python.app/Contents/MacOS/Python.


Testing sys.maxint answers the question whether the current python in  
running in 32 or 64-bit mode.  platform.architecture() just tells if  
the wrapper is "capable" of running 64-bit (it will run 64-bit by  
default on 64-bit architectures, but could actually be running 32-bit,  
either by choice or on 32-bit only hardware), and doesn't say anything  
about the real python executable.


Ed

On Sep 18, 2009, at 5:46 PM, Bill Janssen wrote:

I think I'm just going to put '32bit' or '64bit' in my installer  
name strings.


Bill

[email protected] wrote:


On Sep 18, 2009, at 5:05 PM, Bill Janssen wrote:


William Kyngesburye  wrote:


If you run the CLI 'uname -m' on any Intel Mac, it always has
returned
i386.  So all it really means is 'Intel'.

On Sep 18, 2009, at 5:53 PM, Bill Janssen wrote:


I'm running /usr/bin/python on SL, and

 import platform; print platform.machine()

give me

 i386

But Activity Monitor shows Python as "Intel (64-bit)".

Is this a bug in platform.machine(), or am I misunderstanding what
i386
means?  "platform.architecture()" returns ('64bit', '').


Hmmm.  So what's the pythonic way of getting i386 vs. x86_64?

{'32bit': 'i386', '64bit': 'x86_64'}[platform.architecture()[0]]

seems so complicated that there should be a routine for it in sys or
platform.


I don't know the "official" way, but what I do is:

% python -c 'import sys;print sys.maxint'
9223372036854775807
% env VERSIONER_PYTHON_PREFER_32_BIT=1 python -c 'import sys;print
sys.maxint'
2147483647

So I would look at sys.maxint to determine if python is running 32 or
64-bit.

Ed


___
Pythonmac-SIG maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/pythonmac-sig


Re: [Pythonmac-SIG] machine architecture 32/64 with Python 2.6 on Snow Leopard?

2009-09-19 Thread Bill Janssen
You could also use other test I've seen:

  def arch():
 import ctypes
 return {4: "i386", 8: "x86_64"}[ctypes.sizeof(ctypes.c_size_t)]

Bill
___
Pythonmac-SIG maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/pythonmac-sig


Re: [Pythonmac-SIG] [BangPypers] python-sap webservices

2009-09-19 Thread bhaskar jain
"__future__ is a special module used to change the behaviour of the parser,
so it is extremely important that it occur in the beginning of your module.
 Just move the imports to the top of your code, and that's all there is to
it."



On Thu, Sep 10, 2009 at 10:02 AM, sudhakar s  wrote:

> Hi,  This is sudhakar, i am using python frame work and now concentrating
> on working on web services in python.
>I installed SOAPpy-0.12.0 on mac but getting errors as below:
>
> venj:SOAPpy-0.12.0 venkata$ python setup.py build
>
> Traceback (most recent call last):
>
>   File "setup.py", line 8, in 
> from SOAPpy.version import __version__
>   File "/Applications/SOAPpy-0.12.0/SOAPpy/__init__.py", line 5, in
> 
> from Client  import *
>   File "/Applications/SOAPpy-0.12.0/SOAPpy/Client.py", line 46
> from __future__ import nested_scopes
>
> SyntaxError: from __future__ imports must occur at the beginning of the
> file
>
> venj:SOAPpy-0.12.0 venkata$ python setup.py install
>
> Traceback (most recent call last):
>   File "setup.py", line 8, in 
> from SOAPpy.version import __version__
>   File "/Applications/SOAPpy-0.12.0/SOAPpy/__init__.py", line 5, in
> 
> from Client  import *
>   File "/Applications/SOAPpy-0.12.0/SOAPpy/Client.py", line 46
> from __future__ import nested_scopes
> SyntaxError: from __future__ imports must occur at the beginning of the
> file
>
> Hey please suggest me how to solve this error.
>
> Hey actually whats my requirement is i need to gather information from SAP
> system and Store it in Python appliction server.
> For this i am thinking to construct a web service on python in order to get
> the data from SAP system. Is this the correct way or is there
> any other possibility get in formation and store it in python application
> and i use mysql database for python.
>
> Please give your  valuable suggestion.
>
> Waiting for early reply.
>
> with regards
> S Sudhakar.
>
> ___
> BangPypers mailing list
> [email protected]
> http://mail.python.org/mailman/listinfo/bangpypers
>
>
___
Pythonmac-SIG maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/pythonmac-sig


Re: [Pythonmac-SIG] Link against Python Framework

2009-09-19 Thread Jason Foreman

On Sep 10, 2009, at 5:09 AM, Georg Seifert wrote:



If you want to make absolutely sure that Apple can't break you, you  
could bundle the version of Python.framework upon which you depend  
into your app.  However, that's probably not necessary unless you  
want to use a newer version of Python than the system has (say,  
3.0+, or 2.6 on Leopard).


How do I specify the version to link with.
The 10.5 SDK links against python 2.5 and the 10.6 SDK to 2.6. But  
what if I need the 10.6 SKD but want to link to python 2.5?


This is a good question, and I'm sorry to say I haven't got an answer  
for you.  I'm not sure how to specify which framework version to link  
when you add a framework that contains multiple versions.


What I would probably do myself at that point is to compile a Python  
2.5 framework of my own, and embed it into my app.


I'll try to look for ways to specify a specific framework version to  
link against and let you know if I find anything.



Jason




smime.p7s
Description: S/MIME cryptographic signature
___
Pythonmac-SIG maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/pythonmac-sig


Re: [Pythonmac-SIG] Link against Python Framework

2009-09-19 Thread Jason Foreman


On Sep 10, 2009, at 10:29 AM, Jason Foreman wrote:


On Sep 10, 2009, at 5:09 AM, Georg Seifert wrote:


How do I specify the version to link with.
The 10.5 SDK links against python 2.5 and the 10.6 SDK to 2.6. But  
what if I need the 10.6 SKD but want to link to python 2.5?


I'll try to look for ways to specify a specific framework version to  
link against and let you know if I find anything.


I did find a way to use the 10.6 SDK but still link with Python 2.5.   
However I'd classify this as a 'dirty hack' so I'm not sure I could  
recommend it.


When the linker is linking to a framework, it expects to find (a link  
to) the framework binary at Foo.framework/Foo (e.g. Python.framework/ 
Python).  In the real framework, this is just a symlink to  
Python.framework/Versions/Current/Python, which is of course the 2.6  
version of Python.


We can exploit the fact that same-named frameworks that exist in a  
user-specified framework search path will be used before the ones in  
system search paths.  What you do is create a Python.framework  
directory in your project (or some subdirectory of it) and link  
Python.framework/Python to /System/Library/Frameworks/Python.framework/ 
Version/2.5/Python.  Then you *should* be able to add this "framework"  
to your project, or do as I did and add "-framework Python" to the  
"Other linker flags" build setting.


I tried this on a little sample project and verified with otool that  
the binary was linked against Python 2.5.


Again, I'm not sure you want to do this, but if you can't find any  
other way to solve your issues this may work for you.



Jason




smime.p7s
Description: S/MIME cryptographic signature
___
Pythonmac-SIG maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/pythonmac-sig


Re: [Pythonmac-SIG] Using Python 2.5 on Snow Leopard

2009-09-19 Thread Nicholas Riley
On Fri, Sep 11, 2009 at 08:02:10PM +0100, Thijs Triemstra | Collab wrote:
> 
> On 11 Sep 2009, at 18:50, Bill Janssen wrote:
> 
> >I was happy to see that Python 2.5 still shipped with SL, but now I'm
> >less happy.  I can't seem to compile PIL for Python 2.5 on Snow  
> >Leopard.
> 
> Hm, haven't upgraded to snow leopard yet but i'd expect 2.6 to be in  
> there.. heard they also removed twisted :(

2.5 and 2.6 both ship with SL, just built differently - Python 2.5 is
obviously there for compatibility with Leopard, which I really
appreciate.

% lipo -info /usr/bin/python2.[56]
Architectures in the fat file: /usr/bin/python2.5 are: i386 ppc7400 
Architectures in the fat file: /usr/bin/python2.6 are: x86_64 i386 ppc7400 

and Twisted is there still too:

% find 
/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/twisted
 | wc -l
1675
% find 
/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/twisted
 | wc -l
1675

-- 
Nicholas Riley 

___
Pythonmac-SIG maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/pythonmac-sig


[Pythonmac-SIG] Icon in py2app

2009-09-19 Thread Manuel Kaufmann
Hello! I'm making an app with py2app[1] utility but I can't put my
icon in the dock bar. When I compile my app with py2app I see the icon
in my app folder when I explore it with Finder, but when I run my app
the icon doesn't appear in my dock bar.

I'm using "CFBundleIconFile"[2] option in my "plist" dictionary and I
tried with "--iconfile" too, but both doesn't work.

Can you help me?

[1] http://svn.pythonmac.org/py2app/py2app/trunk/doc/index.html
[2] 
http://developer.apple.com/mac/library/documentation/MacOSX/Conceptual/BPRuntimeConfig/Articles/PListKeys.html#//apple_ref/doc/uid/20001431-102043

-- 
Kaufmann Manuel
Blog: http://humitos.wordpress.com/
PyAr: http://www.python.com.ar/
___
Pythonmac-SIG maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/pythonmac-sig


[Pythonmac-SIG] Using Setuptools with macPython

2009-09-19 Thread Saint One
Hi all,

I have mac os x 10.4 which was shipped with python2.3. Now I am trying to
work with eazyInstall (
http://peak.telecommunity.com/DevCenter/EasyInstall#installation-instructions)
with python2.5. I have upgraded to python2.5 now, but there seems
inconsistency going through my installation directories. I have
/usr/lib/python2.3/ instead of /usr/lib/python2.5/ which is what I want and
this is causing problems when running python from X11 terminal. How do I
upgrade this folder, and most importantly, how do I do a global upgrade of
python in my mac.

Thank you so much in advance for any help.

Cheers,
Ezru.
___
Pythonmac-SIG maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/pythonmac-sig


[Pythonmac-SIG] py2app sip recipe and Qt plugins

2009-09-19 Thread Marc-Antoine Parent

Good day!
I was trying my hand at wrapping a PyQt application, and I stumbled on  
the plugin issue that seems to have plagued many here, where the  
plugins load another copy of the Qt frameworks, indicated as such:


On Mac OS X, you might be loading two sets of Qt binaries into the  
same process. Check that all plugins are compiled against the right Qt  
binaries. Export DYLD_PRINT_LIBRARIES=1 and check that only one set of  
binaries are being loaded.


I looked a bit at how to fix this, and here is what worked for me. I  
have not yet written code to automate this process; but this  
description may be useful to people willing to fix executables by hand.


a) copy the plugin directory from /Developer/Applications/Qt/plugins  
to dist//Contents/plugins


b) Create a file dist//Contents/Resources/qt.conf
with contents as follows:
[Paths]
qt_plugpath=plugins

The path is relative to Contents. Another path could be chosen, that  
could be more congenial to py2app.


c) Adjust the paths of the plugins with install_name_tool. Eg, from  
the shell:


find dist//Contents/plugins -type f -exec  
install_name_tool -change QtGui.framework/Versions/4/QtGui  
@executable_path/../Frameworks/QtGui.framework/Versions/4/QtGui  {} ';'
find dist//Contents/plugins -type f -exec  
install_name_tool -change QtGui.framework/Versions/4/QtCore  
@executable_path/../Frameworks/QtCore.framework/Versions/4/QtCore  {}  
';'

(and so on if you need QtXml etc.)

Cheers,
Marc-Antoine Parent

___
Pythonmac-SIG maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/pythonmac-sig