[Pythonmac-SIG] Installing modules with py2app

Christopher Barker Chris.Barker at noaa.gov
Wed Jan 19 01:02:09 CET 2011


On 1/18/11 2:47 PM, Mier, Alejandro wrote:
> I modified the included distutils files, and managed to get this stack trace
>
> Traceback (most recent call last):
>    File "distutils/dist.py", line 837, in get_command_class
>      __import__ (module_name)
>    File "distutils/command/install.py", line 21, in<module>
>      from site import USER_BASE
> cannot import name USER_BASE
>
> The site.py included in the bundle has this comment: This is stripped down and customized for use in py2app applications
>
> So apparently, py2app is removing USER_BASE and USER_SITE from site.py. I am not sure why it does that, but it is preventing the installation of modules with py2app.
>
> I worked around it by modifying the included site.py to declare USER_BASE and USER_SITE after generating the .app bundle.
>
> I think this might be a bug in py2app, but would like to know your input on this.

I don't think it's a bug -- you may have some problems with this. I'm 
not sure I quite get what distutils is doing with USER_BASE and 
USER_SITE, but I suspect that they are using them to figure out where to 
install stuff. That should be a function of the python you are 
installing to. A py2app bundle isn't usually installing stuff into itself.

How are you using distutils in this case? Are you installing stuff into 
the app bundle? Or into a system python? If a system python, you should 
probably use the system python's distutils (and thus its site.py) to do 
the work.

If you are installing into the app bundle (cool idea!), then you'll need 
to make sure that USER_BASE and USER_SITE are set correctly at run time 
for where the user happens to have put the py2app bundle.

-Chris







-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov


More information about the Pythonmac-SIG mailing list