[Pythonmac-SIG] Workaround: XCode fails to see py2app

Wolfram Eifler adagio at cs.tu-berlin.de
Mon Sep 17 17:59:11 CEST 2007


The Problem:
------------
Building an python-project from xcode results in:
ImportError: No module named py2app
		ImportError: No module named py2app

maybe it arises only if more than one python-version are (or have  
been) installed on the mac
where the building takes place. maybe only in combination with  
installs of PyObjC with the
dmg-installers. I had not the possibility to verify these to  
assumptions.

there has been the proposal to change the first line of setup.py from
	#!/usr/bin/env python
to
	#!<insert absolute path of your python-interpreter>
somwhere on the internet. That works but is ---- *BAD* !!!!  
Programming Style ----.

I stumbled about the fact that the build worked when using the  
teminal - even if i
used exactly the same Command and options, which xcode does. The  
Difference turned
out to be the search-path of the user. My shell-environment has the  
location of python
in it.
So instead of crunching the code of every setup.py i wrote a shell- 
snippet named
xcode-pyhelper.sh as follows:

-------------script begins ----------
#!/bin/sh
PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:${PATH}"
/usr/bin/env python $*
-------------script ends   ----------

i put it in my home-directory /Users/my_username/bin/xcode-pyhelper.sh
and changed the project-build-preferences in xcode (while project is  
open)
via
	project -> Edit active Target
	(window pops up, containing the string /usr/bin/env in the field  
Build-Tool)
	changed the Build-Tool to my brandnew threeline-script
	/Users/my_username/bin/xcode-pyhelper.sh

Build works. This method is ugly too, but at least i do not need to  
coding-style that
securely would fail on all non-mac Platforms (Or does anybody else  
install python in *that*
location... ?).

:) adagio


More information about the Pythonmac-SIG mailing list