Re: Application Packages

2009-09-15 Thread Dj Gilcrease
when looking up namespace-packages I found pkgutil which lets me add a
myapp.user package with the following in its __init__.py and nothing
else

import os, os.path

from pkgutil import extend_path
homedir = os.environ.get('HOME') or os.environ.get('USERPROFILE')
__path__ = extend_path([os.path.abspath(homedir + os.sep + 'myapp')], __name__)



now I can do "from myapp.user.plugins import *" and it works
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Application Packages

2009-09-15 Thread Diez B. Roggisch

Dj Gilcrease schrieb:

Say I have an application that lives in /usr/local/myapp it comes with
some default plugins that live in /usr/local/myapp/plugins and I allow
users to have plugins that would live in ~/myapp/plugins

Is there a way to map ~/myapp to a user package so I could do "from
user.plugins import *" or better yet map it to myapp.user?


No. You can execfile things in there, or you can add ~/myapp to the 
sys.path and then import things in there. And you can create aliases for 
those of course.


Alternatively, namespace-packages and virtualenvs might be a solution, 
but not exactly straight-forward as well.


Diez
--
http://mail.python.org/mailman/listinfo/python-list


Application Packages

2009-09-15 Thread Dj Gilcrease
Say I have an application that lives in /usr/local/myapp it comes with
some default plugins that live in /usr/local/myapp/plugins and I allow
users to have plugins that would live in ~/myapp/plugins

Is there a way to map ~/myapp to a user package so I could do "from
user.plugins import *" or better yet map it to myapp.user?


Dj Gilcrease
OpenRPG Developer
~~http://www.openrpg.com
-- 
http://mail.python.org/mailman/listinfo/python-list