On 17 Oct, 2012, at 16:12, Emanuele Santos <emanuelesan...@gmail.com> wrote:

> Hi, all
> 
> We build a bundle with py2app and we would like to make it extensible so 
> users could install on demand other python packages into the python framework 
> included in the bundle, for example by running easy_install.
> 
> Is there a recommended way of doing that? I noticed that the site.py file 
> included in the bundle is not complete so when I tried using the --user 
> command line option or setting the $PYTHONHOME, I got an error.

I wouldn't change the application bundle itself, but would add an option to 
load python code from a user specified location. There are two reasons for not 
changing the application bundle itself: that would invalidate code signatures, 
and users cannot necessarily write into the bundle (I tend to install 
applications using a separate account with more privileges than my normal 
account).

One way to do this is adding something like this to your application's startup 
code:

    import os
    import site

    site.addsitedir(os.path.expanduser("~/Library/Application 
Support/MyApp/Python"))

Users can then install additional modules in "~/Library/Application 
Support/MyApp/Python" and your application can then use them.

If you're using a semi-standalone build (for example because you use Apple's 
python build) you can also use the "--site-packages" option to add the default 
site-packages directory to your application's search path. However, when I look 
at the code that not only just works for semi-standalone builds, but I'm also 
also not sure if the code that adds ~/Library/Python/... to sys.path actually 
works.

Ronald
> 
> Thanks,
> 
> -- Emanuele.
> 
> _______________________________________________
> Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
> http://mail.python.org/mailman/listinfo/pythonmac-sig
> unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG

_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG

Reply via email to