[Pythonmac-SIG] Installing modules with py2app

Mier, Alejandro alejandro at ti.com
Thu Jan 20 23:10:15 CET 2011


Hi Chris

> 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.

I am trying to install modules into the system python.

The problem with my solution (which I hadn't notice); is that modules are getting installed into the .app bundle instead.

The problem is that, even though subprocess.call("python setup.py install") picks up the system python (sys.executable has the expected value), it still loads the modules from the site-packages.zip in the .app bundle.

How can I make this new python process load the modules from system site-packages folder?

Thanks

------------------------------
Alejandro Mier y Concha


-----Original Message-----
From: pythonmac-sig-bounces+alejandro=ti.com at python.org [mailto:pythonmac-sig-bounces+alejandro=ti.com at python.org] On Behalf Of Christopher Barker
Sent: Tuesday, January 18, 2011 6:02 PM
To: pythonmac-sig at python.org
Subject: Re: [Pythonmac-SIG] Installing modules with py2app

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
_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG at python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG


More information about the Pythonmac-SIG mailing list